Validating the email
From this day forward, you will no longer squander your time trying to work out the perfect regex to validate email addresses.You will also never again run the risk of rejecting what is, in fact, a strange, valid email address.(The flip side is I fail and be told my address isn’t valid when it is! She regrets buying the domain, too, but won’t give it up, just like the guy that’s got I am more likely to mis-type with a letter on the visible keyboard with no shift key required (I apply a weighting to non-modified keys in the model). So from a list of 117 million email addresses I have calculated the frequency of occurrence of each character and for each, noted which keys lie closest on the keyboard, and factored in the likelihood that a mis-stroke will create an invalid email address.
However, in the real world ESPs accept addresses that are not RFC-valid, and reject addresses that are.
The trick is to first define what we mean by ‘valid’.
We are developers, we are technical folk, so it’s no surprise that the prevailing wisdom is to check that it matches the official criteria, some examples of the diversity of the official criteria are…If you have a well laid-out form with a label that says “email”, and the user enters an ‘@’ symbol somewhere, then it’s safe to say they understood that they were supposed to be entering an email address. Next, we want to do some validation to ascertain if they correctly entered right?
Here's an example of the above in action: Almost all answers to this questions suggest using Regex to validate emails addresses.
I think Regex is only good for a rudimentary validation. Then it tells you whether the email address is real or not.Some mail servers do not co-operate in the process, in such cases, the result of this email verification tool may not be as accurate as expected.That’s 27 stabs at the keyboard that could go awry.