LoginSignup
1
1

More than 5 years have passed since last update.

PHPで正規表現のバリデーション

Last updated at Posted at 2018-03-14
$input_string = '^([\s\S]*)$';

@$result = preg_match('/'.$input_string.'/u', '', $match_list);// uはマルチバイト対応

if ($result === false)
{
    // バリデーションエラー
}

preg_match

preg_match() は、pattern が指定した subject に
マッチした場合に 1 を返します。
マッチしなかった場合は 0、
エラーが発生した場合は FALSE を返します。

1
1
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
1
1