RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find RFC2822 Compliant Email Check
Expression
^(([-\w$%&'*+\/=?^_`{|}~.]+)@(([-a-zA-Z0-9_]+\.)*)([-a-zA-Z0-9]+\.)([a-zA-Z0-9]{2,7}))?$
Description
RFC2822 compliant email matching regex that doesn't assume TLDs are set for all time. Clearly this means that someone could get a 2 letter country code wrong, but since no TLD is set in stone, I prefer to match future possibilities as well. This also conforms to what traditional DNS can do w/r/t hostnames and domain names.
Matches
Non-Matches
aoluser1
Author Rating: The rating for this expression. David Kearns
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Example - followup
Name: Gary
Date: 6/7/2007 5:04:25 AM
Comment:
Just saw the test button. I made a mistake with [email protected] it doesn't match but [email protected] would match, again maybe this is a valid address?? Finally, like I thought entering nothing matches as well so the {1} is needed. Cheers, Gary


Title: Example
Name: Gary
Date: 6/7/2007 4:56:23 AM
Comment:
I haven't read the RFC in question but I think your expression would match the following: [email protected] [email protected] are these valid e-mail addresses? Maybe they are, like I said I am not sure. Also the ? in your expression ^( some pattern )?$ matches zero or 1 times. I think you should change the ? to a {1} Regards, Gary.


Title: Examples, please
Name: David Kearns
Date: 5/8/2007 4:45:15 PM
Comment:
And how does this not conform to the RFC in question? Criticism like this is rather unhelpful, you don't provide a proper solution or even provide examples of how this is wrong.


Title: WRONG WRONG WRONG
Name: Randal L. Schwartz
Date: 4/27/2007 9:46:10 AM
Comment:
Once again, you even cite the right RFC, but you are NOT implementing the RFC. WHY IS MATCHING EMAIL SO HARD FOR PEOPLE TO UNDERSTAND? {sigh}


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials