module Regexifi::Email
Constants
- DEVISE
Used by a popular authentication gem Devise
- IDN
Based on the Devise Regexp above, but actually UTF-8 /
IDN
friendly If you need to pass internationalized domains (IDN
) - en.wikipedia.org/wiki/Internationalized_domain_name that use Cyrillic or Asian characters for example, this might be a better choice.- RAILS_TUTORIAL
This is a commonly seen in Rails apps regex from Michael's Hartl's tutorial IT's similar to DEVISE's default Regex with slight modification ( not allowing 1-letter TLDs) Original = /A+@[a-zd-]+(.+)*.[a-z]+z/ix.freeze
- RFC5322
RFC1123 = /A(?<domain>(?!.{254,})((((([A-Za-z0-9])(){0,62}.)*([A-Za-z]) ([A-Za-z0-9-]){0,62}))|((?:(?:25|2[0-9]|?[0-9]?).){3} (?:25|2[0-9]|?[0-9]?))))Z/ix
- RFC6068
RFC6068
defines the whole URI spec, but for out purposes here we just need email address REGEXP, which currently is defined as this /A+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61})? (?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61})?)*z/ix However if you don't have a compelling reason to spell it out, it is recommended to use REGEX defined in Ruby's standard library- WHATWG
This is a standard developed by
WHATWG
- Web Hypertext Application Technology Working Group based on the RFC1123 standard that defines rules for domains. html.spec.whatwg.org/multipage/input.html#valid-e-mail-address