Email validating regular expression

But the alternative - such as what's being attempted here - is a nightmare!

Even if there was a standardised regex for all emails, which would not break when new TLDs are released, or new unicode characters are supported, or whatever, there would still be no guarantee that [email protected] actually valid!

Instead of having a monstrous regex pattern in my code I simply email a confirmation link the user must confirm.

That's the thing, the only way to validate an email address anyway is to actually have the user take some action to do so.

Unfortunately, I bet there are thousands of "real systems" employing regexes like this... The third party was rejecting the data we were trying to send them as the email addresses were apparently invalid.I simply don't validate emails up front anymore.The only thing I check for is if the string contains an @-char, I only do that to be nice if it's left out by accident.If you really want to do some clientside validation, just keep a basic regex and warn the user if the address doesn't seem right.. If you check for a valid mail server at that domain, you can reduce that to 0.If you connect to their server and check for an error for that mailbox, you can reduce your soft bounces to 0 too, but that requires a lot of legwork to set up.

Leave a Reply