2
0

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 3 years have passed since last update.

メールアドレスを正規表現で指定する

2
Posted at

指定したいメールアドレス例

example@example.com

メールアドレスにマッチする正規表現

^[a-zA-Z0-9_.+-]+@([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$

ローカル部分( @ よりも前の部分)には仕様上はかなり多くの文字を使用できるが、Outlookを参考に
アルファベット(a-z)、数字(0-9)、ピリオド(.)、プラス(+)アンダーバー(_)ハイフン(-)を指定し以下のように記載。

[a-zA-Z0-9_.+-]+

ドメイン名はトップレベルドメインで使用できる文字はアルファベット(a-z)となっており、トップレベルドメイン以外のラベルについては数字(0-9)やハイフン(-)も利用可能。ただしハイフンはラベルの先頭と最後には使えない。
トップレベルドメイン部分

[a-zA-Z]{2,}$

それ以外のラベル部分

([a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]*\.)+

多分これで指定できるかと思います・・・。ご利用は計画的に。

2
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?