I realize that there are a ton of regex email validations, but I can't seem to find one that adheres to the RFC 2822
standard.
The ones I find keep letting in junk like ..@abc.com get through.
Forgive me if the one of the questions is already answered adhering to RFC 2822 (but not annotated that it is).
This runs in PCRE: http://code.iamcal.com/php/rfc822/full_regexp.txt
It's 32k, apparently.
Seriously - maybe consider backing off using a single regexp, or accepting ALL possible email forms.
I would look at this: http://www.regular-expressions.info/email.html, which explains a lot about using regular expressions to match email addresses, and includes a full RFC 2822 expression which honestly I would almost never recommended using.
This is for RFC822, not for the newer one. But it seems the address format has not been changed, so should be what you're looking for.
(note the remark below the regexp--it still assumes that the address has been preprocessed)
I did a post on this a short while ago. Yes, it is possible using .NET regex, since they have a non-regular feature called "balancing groups".
The Perl RFC822 one that is often posted doesn't fully match email addresses, since it requires preprocessing to remove comments. It's also for a very old RFC (from 1982!).
This regex is for RFC5322, which is current. It also handles all comments and folding whitespace correctly.
Here is the regex:
Some caveats, however. RFC5322 is more liberal with domain names than the actual domain RFCs, and there are other restrictions that apply from various RFCs such as the actual SMTP RFC itself (which specifies a maximum length). So even though an email is correct according to 5322 it can be invalid by various other measures.
The golden test is still to send an email to the address with a validation code.