Module: Regexifi::Email
- Defined in:
- lib/regexifi/email.rb
Constant Summary collapse
- DEVISE =
Used by a popular authentication gem Devise
/^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i.freeze
- 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.
/^([[[:word:]]\.%\+\-]+)@([[[:word:]]\-]+\.)+([[:alpha:]]{2,})$/i.freeze
- RAILS_TUTORIAL =
/\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]{2,}+\z/i.freeze
- 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
%r{^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+ @[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])? (?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$}ix.freeze
- RFC5322 =
%r{\A(?<local>(([A-Za-z0-9!#\$%&'*\+\-/=\?\^_`\{\}\|~])+)(\.([A-Za-z0-9!#\$%&'*\+\-/=\?\^_`\{\}\|~])+)*) @((?<domain>(?!.{254,})((((([A-Za-z0-9])([A-Za-z0-9\-]){0,62}\.)*([A-Za-z])([A-Za-z0-9\-]){0,62}))| ((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)))))\Z}ix.freeze
- 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](?:0,61)? (?:.[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
URI::MailTo::EMAIL_REGEXP