I'm using the following for email validation:
var filter = /^(\w+)(\.\w+)*@(\w+)(\.\w+)+$/;
Just noticed that it does not support xxxx+wildcard@gmail.com (it does not support the +wildcard part). Any way to get that added?
I'm using the following for email validation:
var filter = /^(\w+)(\.\w+)*@(\w+)(\.\w+)+$/;
Just noticed that it does not support xxxx+wildcard@gmail.com (it does not support the +wildcard part). Any way to get that added?
You should use \S+@\S+\.\S+
, which will match anything with an @
and a .
.
Anything more than that will reject valid but obscure addresses.
Even this will reject valid but obscure addresses, such as "Test Me"@localhost
.
However, these are never used in practice. [citation needed]
I liked SLak's answer. I actually have a regular expression I wrote awhile back that's even more open-ended.
^.+@.+\..+$
The idea behind it is similar. Don't try so hard. Instead, err on the side of accepting too much. To my knowledge this regex should accept every conceivable valid email address (and some invalid ones as well).