I've been trying to create a reg ex that supports gmail's "plus":
name+thing@gmail.com
^[\w-.]+@([\w-]+.)+[\w-]{2,4}$
How do I allow the + ?
I've been trying to create a reg ex that supports gmail's "plus":
name+thing@gmail.com
^[\w-.]+@([\w-]+.)+[\w-]{2,4}$
How do I allow the + ?
As others said, it's so hard to validate an email-address exactly. But we could do a low level validation. For validation, you don't need to capture anything. So turn the capturing group in your regex to non-capturing group.
^[\w-.+]+@(?:[\w-]+.)+[\w-]{2,4}$
There is only one truly reliable way to store only real email addresses in your database: send a confirmation mail with a confirmation link. vladimir.poetin@whitehouse.gov
will pass all checks, but is very probably not a real address.
To catch typos by the user, and thus prevent unnecessary action by your server, just have him/her enter the address twice, and compare the inputs.