There's no one regular expression that can detect whether any given email is valid. There are too many possible forms and too many possibilities.
Example 1: Non-ASCII domain names will cause simple regular expressions to fail. [A-Za-z0-9] is not enough to contain all the possibilities of Chinese or Middle Eastern sites.
Example 2: It's perfectly valid for an email address to be of the form xyz@alpha.beta.gamma.delta.epsilon.somewhere.com, which "violates" the common "a@b.c.com" format.
Example 3: There are non-standard exceptions to the general "a@b.c.com" format. Consider exex!research!ucbvax!user@ketch-ai, a valid uucp address.
In the final analysis, the only way to know if an email address is valid is to send to that address.
johnson1
ASKER
What would be a minimum check?
How can I check if it contains
name (1) - john
@ (2)
(3)domain - yahoo.com
and check if @ comes between the name and the domain, but not like yahoo.com@john
I use the format of 'a@b.c'. There are no single letter user names or domain names that I know of. I did run into one user with a 2 letter user name. I don't use Regex though.
1. split the name at @. If there is no @, it is not valid.
2. the first part before the '@' must be greater than 1 character. It can contain '.'.
3. split the second part after the '@' on '.'.
4. each part of the second part must be greater than 1 character. There are some TLDs like 'tv' that are only 2 letters.
http://regexr.com/3bcrb
you can go to Community tab and search for other available email regular expressions.
or you can try this:
http://www.regular-expressions.info/email.html