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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Email validation
Expression
^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.(af|ax|al|dz|as|ad|ao|ai|aq|ag|ar|am|aw|au|at|az|bs|bh|bd|bb|by|be|bz|bj|bm|bt|bo|ba|bw|bv|br|io|bn|bg|bf|bi|kh|cm|ca|cv|ky|cf|td|cl|cn|cx|cc|co|km|cg|cd|ck|cr|ci|hr|cu|cy|cz|dk|dj|dm|do|ec|eg|sv|gq|er|ee|et|fk|fo|fj|fi|fr|gf|pf|tf|ga|gm|ge|de|gh|gi|gr|gl|gd|gp|gu|gt| gg|gn|gw|gy|ht|hm|va|hn|hk|hu|is|in|id|ir|iq|ie|im|il|it|jm|jp|je|jo|kz|ke|ki|kp|kr|kw|kg|la|lv|lb|ls|lr|ly|li|lt|lu|mo|mk|mg|mw|my|mv|ml|mt|mh|mq|mr|mu|yt|mx|fm|md|mc|mn|ms|ma|mz|mm|na|nr|np|nl|an|nc|nz|ni|ne|ng|nu|nf|mp|no|om|pk|pw|ps|pa|pg|py|pe|ph|pn|pl|pt|pr|qa|re|ro|ru|rw|sh|kn|lc|pm|vc|ws|sm|st|sa|sn|cs|sc|sl|sg|sk|si|sb|so|za|gs|es|lk|sd|sr|sj|sz|se|ch|sy|tw|tj|tz|th|tl|tg|tk|to|tt|tn|tr|tm|tc|tv|ug|ua|ae|gb|us|um|uy|uz|vu|ve|vn|vg|vi|wf|eh|ye|zm|zw|com|edu|gov|int|mil|net|org|biz|info|name|pro|aero|coop|museum|arpa))|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$
Description
This is a robust email validation: the username part conforms with RFC 2822 (for instance, emails with tags ("+") are validated). The host part is checked for valid subdomains and its TLD is checked against all the 243 countries codes and the 14 ICANN'sTLDs. The host part also accepts IP with or without brackets.
Matches
Non-Matches
Author Rating: The rating for this expression. Philippe Benthien
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: Complete list of TLDs
Name: Ergin BULUT
Date: 3/15/2015 5:30:04 AM
Comment:
To view complete list of TLDs, you can visit http://data.iana.org/TLD/tlds-alpha-by-domain.txt and modify TLDs part of the regex pattern.


Title: Corrected: Complete list of TLSs as of 21/02/2014
Name: Ryan Penfold
Date: 2/21/2014 11:23:54 AM
Comment:
^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.(AC|ACADEMY|AD|AE|AERO|AF|AG|AGENCY|AI|AL|AM|AN|AO|AQ|AR|ARPA|AS|ASIA|AT|AU|AW|AX|AZ|BA|BARGAINS|BB|BD|BE|BERLIN|BF|BG|BH|BI|BIKE|BIZ|BJ|BLUE|BM|BN|BO|BOUTIQUE|BR|BS|BT|BUILD|BUILDERS|BUZZ|BV|BW|BY|BZ|CA|CAB|CAMERA|CAMP|CARDS|CAREERS|CAT|CATERING|CC|CD|CENTER|CEO|CF|CG|CH|CHEAP|CI|CK|CL|CLEANING|CLOTHING|CLUB|CM|CN|CO|CODES|COFFEE|COM|COMMUNITY|COMPANY|COMPUTER|CONDOS|CONSTRUCTION|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IAL|SOLAR|SOLUTIONS|SR|ST|SU|SUPPORT|SV|SX|SY|SYSTEMS|SZ|TATTOO|TC|TD|TECHNOLOGY|TEL|TF|TG|TH|TIENDA|TIPS|TJ|TK|TL|TM|TN|TO|TODAY|TOKYO|TOOLS|TP|TR|TRAINING|TRAVEL|TT|TV|TW|TZ|UA|UG|UK|UNO|US|UY|UZ|VA|VC|VE|VENTURES|VG|VI|VIAJES|VILLAS|VISION|VN|VOTING|VOYAGE|VU|WANG


Title: Complete list of TLDs as of 21/02/2014
Name: Ryan Penfold
Date: 2/21/2014 11:02:10 AM
Comment:
ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cw|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sjsk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yuza|zm|zw http://www.ryanpenfold.com


Title: Excellent expression
Name: Phil
Date: 2/19/2014 3:58:49 AM
Comment:
Excellent regular expression... probably saved me days of work finding this. I'm using it from c# and it does everything I wanted... validates all valid email addresses I can test it with except ones with quotes or comments (which I don't want to accept anyway). I changed the TLD part to just check for 2 to 6 characters just to avoid having to add new ones. For anybody complaining that a single TLD is missing... just add it in. Its not difficult and all the hard work is done for you here.


Title: Excellent expression
Name: Phil
Date: 2/19/2014 3:58:26 AM
Comment:
Excellent regular expression... probably saved me days of work finding this. I'm using it from c# and it does everything I wanted... validates all valid email addresses I can test it with except ones with quotes or comments (which I don't want to accept anyway). I changed the TLD part to just check for 2 to 6 characters just to avoid having to add new ones. For anybody complaining that a single TLD is missing... just add it in. Its not difficult and all the hard work is done for you here.


Title: Real world
Name: Blah
Date: 5/19/2007 4:45:35 PM
Comment:
The real world doesn't include the UK?


Title: .eu is missing
Name: christian
Date: 5/9/2007 7:02:57 AM
Comment:
.eu-domains are not included!


Title: Doesn't work for javascript
Name: John A. Davis
Date: 2/25/2007 8:44:50 PM
Comment:
For some reason just copying and pasting it into the place ,where I have a shorter working javascript regex string, doesn't work: function test(src) { //var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$"; var emailReg = "^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.(af|ax|al|dz|as|ad|ao|ai|aq|ag|ar|am|aw|au|at|az|bs|bh|bd|bb|by|be|bz|bj|bm|bt|bo|ba|bw|bv|br|io|bn|bg|bf|bi|kh|cm|ca|cv|ky|cf|td|cl|cn|cx|cc|co|km|cg|cd|ck|cr|ci|hr|cu|cy|cz|dk|dj|dm|do|ec|eg|sv|gq|er|ee|et|fk|fo|fj|fi|fr|gf|pf|tf|ga|gm|ge|de|gh|gi|gr|gl|gd|gp|gu|gt| gg|gn|gw|gy|ht|hm|va|hn|hk|hu|is|in|id|ir|iq|ie|im|il|it|jm|jp|je|jo|kz|ke|ki|kp|kr|kw|kg|la|lv|lb|ls|lr|ly|li|lt|lu|mo|mk|mg|mw|my|mv|ml|mt|mh|mq|mr|mu|yt|mx|fm|md|mc|mn|ms|ma|mz|mm|na|nr|np|nl|an|nc|nz|ni|ne|ng|nu|nf|mp|no|om|pk|pw|ps|pa|pg|py|pe|ph|pn|pl|pt|pr|qa|re|ro|ru|rw|sh|kn|lc|pm|vc|ws|sm|st|sa|sn|cs|sc|sl|sg|sk|si|sb|so|za|gs|es|lk|sd|sr|sj|sz|se|ch|sy|tw|tj|tz|th|tl|tg|tk|to|tt|tn|tr|tm|tc|tv|ug|ua|ae|gb|us|um|uy|uz|vu|ve|vn|vg|vi|wf|eh|ye|zm|zw|com|edu|gov|int|mil|net|org|biz|info|name|pro|aero|coop|museum|arpa))|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$"; var regex = new RegExp(emailReg); return regex.test(src); }


Title: Ok, I'm gonna give it a go
Name: John A. Davis
Date: 2/18/2007 9:01:26 PM
Comment:
Seems to work ok. Here is how I am using it in ASP.NET Dim strYourEmail As String = Request.Form.Get("txtYourEmail").ToString.Trim 'This is a robust email validation: the username part conforms with RFC 2822 (for instance, emails with tags ("+") are validated). The host part is checked for valid subdomains and its TLD is checked against all the 243 countries codes and the 14 ICANN'sTLDs. The host part also accepts IP with or without brackets. 'http://regexlib.com/REDetails.aspx?regexp_id=1448 Dim mRegExp As New Regex("^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.(af|ax|al|dz|as|ad|ao|ai|aq|ag|ar|am|aw|au|at|az|bs|bh|bd|bb|by|be|bz|bj|bm|bt|bo|ba|bw|bv|br|io|bn|bg|bf|bi|kh|cm|ca|cv|ky|cf|td|cl|cn|cx|cc|co|km|cg|cd|ck|cr|ci|hr|cu|cy|cz|dk|dj|dm|do|ec|eg|sv|gq|er|ee|et|fk|fo|fj|fi|fr|gf|pf|tf|ga|gm|ge|de|gh|gi|gr|gl|gd|gp|gu|gt| gg|gn|gw|gy|ht|hm|va|hn|hk|hu|is|in|id|ir|iq|ie|im|il|it|jm|jp|je|jo|kz|ke|ki|kp|kr|kw|kg|la|lv|lb|ls|lr|ly|li|lt|lu|mo|mk|mg|mw|my|mv|ml|mt|mh|mq|mr|mu|yt|mx|fm|md|mc|mn|ms|ma|mz|mm|na|nr|np|nl|an|nc|nz|ni|ne|ng|nu|nf|mp|no|om|pk|pw|ps|pa|pg|py|pe|ph|pn|pl|pt|pr|qa|re|ro|ru|rw|sh|kn|lc|pm|vc|ws|sm|st|sa|sn|cs|sc|sl|sg|sk|si|sb|so|za|gs|es|lk|sd|sr|sj|sz|se|ch|sy|tw|tj|tz|th|tl|tg|tk|to|tt|tn|tr|tm|tc|tv|ug|ua|ae|gb|us|um|uy|uz|vu|ve|vn|vg|vi|wf|eh|ye|zm|zw|com|edu|gov|int|mil|net|org|biz|info|name|pro|aero|coop|museum|arpa))|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$") If mRegExp.IsMatch(strYourEmail) Then lblValid.Text = "" Else lblValid.Text = "Something is wrong with your email address." lblValid.ForeColor = Red Exit Sub


Title: Forgot mobi
Name: Monkeyget
Date: 10/27/2006 8:22:02 AM
Comment:
Hi, you forgot to add 'mobi' which stands for mobile.


Title: Forgot the UK
Name: dhafer
Date: 10/27/2006 5:09:11 AM
Comment:
Hi, you forgot to add 'uk' for good old England.


Title: Too short for subdomain
Name: quan liang
Date: 9/6/2006 11:40:59 AM
Comment:
why just limit the subdomain to more than one chars?


Title: CORRECT for real word application
Name: Phil Benthien
Date: 8/30/2006 12:03:54 PM
Comment:
I left out quoted string because 1) the definition of quoted string is self recursive 2) in the real word nobody uses it


Title: Still WRONG
Name: Randal L. Schwartz
Date: 8/4/2006 11:45:53 PM
Comment:
THIS IS NOT 2822 YET. You left out quoted strings. Why does everyone keep ignoring http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html ?


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