LoginSignup
2
2

More than 5 years have passed since last update.

文字列が正規表現として有効か確認する

Last updated at Posted at 2015-03-26

preg_match の返り値で判断。

function is_regexp_string($pattern) {
    return @preg_match($pattern, '') !== false;
}

PHP: preg_match - Manual

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2