Read more

Regex pattern to validate email addresses

Martin Straub
October 25, 2012Software engineer at makandra GmbH

Our most recent pattern is

EMAIL = /\A[a-z0-9\+\-_\.]+@[a-z\d\-.]+\.[a-z]+\z/i

Notes

  • Don't replace [a-z0-9\+\-_\.] with \w ! Otherwise the pattern would allow ßs and many other invalid characters.
  • The email address standard Show archive.org snapshot allows more patterns of emails than those which work in practice (e.g. a@a is valid). In result our pattern is more strictly.
  • Caution: john..doe@example.com and john.doe@example..com are accepted as well.
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot
Posted by Martin Straub to makandra dev (2012-10-25 17:05)