Is this email regex valid addresses?
I tried to create a regex that catches all RFC-valid addresses, but it's okay if false positives show up (although hopefully not many). This is so, I got to this:
/^\b\S+@\S+\.[^\s@]{2,}\b$/
Is there any RFC valid address that doesn't match this expression, or do you have any suggestions for improving it? I don't mind false positives, but I would be glad if you could show me a few too.
a source to share
Email addresses can contain nested comments, which spoils most regular expressions. This is a valid email address:
test(Oh (noes, an @) "sign")@(Here comes the domain)domain.com(TLD is com!!)
Even without comments, the local part may contain quoted lines, which may contain spaces. The best approach I've found is search @
. It is necessary. So I would use
/.+@.+/
a source to share
Send a message:
Using a regular expression to validate an email address
There is also this one:
http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html
Nothing like a 6000+ character regex!
a source to share
name@[1.2.3.4]
does not match, but valid. A good list of valid / invalid email addresses for testing can be found here .
a source to share
Try regexbuddy for checking reqular expressions. Another user-friendly site I use regexplib a lot
a source to share