3 ms·
I should point out it's generally not a good idea to try to use regex on an email address. It's surprisingly complex and very easy to miss something. I'd rely o
by ancarda 13y ago
I should point out it's generally not a good idea to try to use regex on an email address. It's surprisingly complex and very easy to miss something. I'd rely on type="email" and send a verification link server-side.
- callahad 13y agoWhat out the WHATWG's take on it: http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#e-mail-state-%28type=email%29 http://www.whatwg.org/specs/web-apps/current-work/multipage/... Specifically, they've redefined the format of email addresses in a way that's much simpler and is actually amenable to regular expressions. "This requirement is a willful violation of RFC 5322, which defines a syntax for e-mail addresses that is simultaneously too strict (before the "@" character), too vague (after the "@" character), and too lax (allowing comments, whitespace characters, and quoted strings in manners unfamiliar to most users) to be of practical use here." The spec even includes a Perl-compatible regex as an example. :)
- deleted 13y ago[deleted]
- ubernostrum 13y agoYou know, I really think at this point that the random historical crap that's technically legal in an email address should be treated the same as if you walked into a restaurant and tried to order in Latin. It's time to retire a lot of it and tell people to move on.
- daker 13y agoExactly :)
- MrDOS 13y agoThat doesn't change the fact that a lot of validators disallow common, everyday things like + tags or even . characters. The only good way to be sure is to make sure the address contains an @ SOMEWHERE other than the last character (.+@.+, maybe), and then send a validation e-mail.