LoginSignup
9
7

More than 3 years have passed since last update.

rubyのmailの正規表現の書き方

Last updated at Posted at 2018-04-24

emailの形式に明確な定義はありませんが、
実用上困らないパターンです。

Railsの公式リファレンスから引用しています。

mailRegex = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
email = "a@a.com"
email.match? mailRegex # =>true
9
7
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
9
7