18
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPメールチェック正規表現

Last updated at Posted at 2016-11-10

###備忘録。
結構適当なので、使用は気を付ける。
記号もパイプ許可とか外した方が精神的に安心だが。

preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\?\*\[|\]%'=~^\{\}\/\+!#&\$\._-])*@([a-zA-Z0-9_-])+\.([a-zA-Z0-9\._-]+)+$/", $mailaddress)

解説
下記を確認。

1.英数字
2.英数字 ? * [ | ] % ' = ~ ^ { } / + ! # & $ . _ -
3.@
4.英数字 _ -
5.ピリオド
6.英数字 . _ -

######※追記
コメント頂いているように生半可なチェックをするぐらいなら下記で判定した方がよいです。

(bool)filter_var($email, FILTER_VALIDATE_EMAIL);
18
18
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?