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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find E-Mail Address by RFC2822 and RFC1035
Expression
^([A-Za-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\}\|\~]+|"([\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x0-\x7F])*")(\.([A-Za-z0-9\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\}\|\~]+|"([\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x0-\x7F])*"))*@([A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9\-]*[A-Za-z0-9])?)*|(1[0-9]{0,2}|2([0-4][0-9]?|5[0-4]?|[6-9])?|[3-9][0-9]?)(\.(0|1[0-9]{0,2}|2([0-4][0-9]?|5[0-5]?|[6-9])?|[3-9][0-9]?)){2}\.(1[0-9]{0,2}|2([0-4][0-9]?|5[0-4]?|[6-9])?|[3-9][0-9]?))$
Description
This will match any valid RFC2822 e-mail address typed into web forms. If does not support comments, display name, or line folding. It does support quoted-strings in the local-part and domains by the RFC 1035 and proper ip addresses. It does relax the RFC1035 rule of not allowing numbers as the first character of a domain name (since they do exist in real life)
Matches
[email protected]|six."Hello\ There"@yahoo.com|[email protected]|Most any valid e-mail
Non-Matches
Don't know any
Author Rating: The rating for this expression. Matthew
Source Mentioned RFCs
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: Non-Matching
Name: mson72
Date: 10/16/2006 9:02:12 AM
Comment:
Hello, when i use your pattern with javascript, e-mail will not match. Here my sample script: function checkEmail() { var p = /<your pattern copy-paste>/; return(p.test(document.forms[0].elements[0].value)); } I use the following e-mail address: test\ [email protected] or "test test"@gmx.net or "test\ test"@gmx.net In all cases, the result of checkEmail is false. What's the reason? Many thanks. Michael


Title: unfortunately, it doesn't say which regex it works with
Name: aaava
Date: 7/13/2006 9:37:49 PM
Comment:
which would be helpful. Is this for the Java/Perl regex or the .NET javascript regex?


Title: ^^^ True
Name: Kevin
Date: 6/9/2006 12:44:20 PM
Comment:
Best email regex by an order of magnitude around here


Title: Finally. Yes. A *real* email validator
Name: Randal L. Schwartz
Date: 3/20/2006 10:59:08 AM
Comment:
I didn't test this, but at least someone is saying "RFC" when mentioning an "email address validator". People, please take note. If your "email validator" isn't at least this long, you aren't doing the right thing! Thanks for this!


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