- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
(\w[-._\w]*\[email protected]\w[-._\w]*\w\.\w{2,3})
This is my all-time favourite e-mail validator. I've used it for years and it's never failed me :-)
Author Rating: The rating for this expression. Darren Neimke
Your Rating
Bad Good

Enter New 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: Underscore is a word character
Name: Jim
Date: 9/19/2014 1:29:14 PM
At least in PHP's Perl-compatible regex. You can say [\w]* instead of [_\w]*

Title: Nowhere near RFC822 compliant
Name: Scott Tadman
Date: 8/6/2010 10:46:42 AM
This is a really naive and incorrect implementation of the RFC822 specification on what an email address can contain. Gmail, as a simple example, permits names like [email protected] which will fail here. There are also top-level domains with more than three letters including ".info" and ".name" which have been around for years. It's woefully inadequate regular expressions like this that infuriate users and kill your sign-up rates.' Although the full regexp is rather unwieldly ( you should at least be more generous than this.

Title: web admin
Name: frank wright
Date: 2/9/2005 11:11:22 AM
this is good but you need to match the last bit with the end of the line \w{2,3}$

Title: Fails to match valid email address
Name: The Fred and Barney Comedy Team <fred&[email protected]>
Date: 1/26/2005 3:37:35 AM
Fails to match the valid email address fred&[email protected]

Title: Don´t discriminate other TLDs!
Name: Sascha
Date: 1/22/2005 7:22:48 AM
This REGEX is not completely correct, as it does not allow any of the following top level domains: - .info - .museum - .aero - .coop - .name See To correct this simply change {2,3} at the end to {2,6} but keep in mind that there might even be longer domains sometime!

Title: Not 100%
Name: Oscar
Date: 1/12/2005 8:17:50 AM
This one does not allow for example .info-domains. It only allows 2 or 3 letters in the top-domain.

Title: didi not work
Name: david
Date: 12/8/2004 6:56:13 AM
this reg exp did not work for my purpose

Title: Here is one that doesn't work
Name: Eric
Date: 7/8/2004 10:43:57 AM
This address doesn't work: [email protected][] Here is one that seems to work great. Yes, it's a bit long. Matches: [email protected], [email protected][], [email protected] ([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))

Title: A+ BS MCSE Web Developer
Name: PersistentMF
Date: 5/6/2004 3:11:10 PM
Darren: Thank you. I am moving away from ColdFusion Javascript & writing my own. The first form that I redid eliminated 40% of the code. It's hard to find all the answers in the same place, but your expression tersely illuminated more things that you can do with RegExp. :)

Title: 4 character TLDs
Name: [email protected]
Date: 4/20/2004 6:43:22 AM
Will this work with .info domain? .. I was looking at the last instruction of your regex, and the {2,3} seems to me to be restricting the TLD of the e-mail adress to maximum 3 characters ?

Title: Soft. Developer
Name: pritam
Date: 4/5/2004 9:30:20 AM
nice results with this email validation reg. expr.

Title: my modifications
Name: Rob Eberhardt
Date: 1/20/2004 7:54:04 AM
not bad. my modifications: /^(\w([-._\w]*\w)*@(\w[-_\w]*\w\.)+\w{2,9})$/ It allows usernames that are 1 or two \w characters, or 3 plus can have -._ between \w characters. It more strongly enforces the domain name pattern, allowing it to be repeated (e.g. It allows 9 character alphabetic-only TLDs (that oughta cover museum and adnauseum :>). Finally, it wraps it up in input start/end characters, to catch invalid junk around a valid address.

Title: Domain extensions can be more than 4 characters
Name: Jason Haymer
Date: 9/2/2003 2:00:54 PM
In response to Kevin's comment which contained: "Also ".com" extensions are always alpha-characters[a-z], and are between 2 to 4 chacaters long, such as .uk or .com. The 4 is there because I've heard(but not seen) that .info is going to be coming out soon." ... In fact they can be longer - ICANN recently took the bizarre step of introducing .museum domains e.g. . And .info, .aero, .coop etc have been around since 2001. I notice that many email regexps in this site ignore these facts.

Title: Re: It's not perfect however
Name: Darren Neimke
Date: 8/31/2003 7:09:49 PM
Ted, It does match on "[email protected]" if you don't put a 'beginning of line' anchor at the start like so: ^\w[-._\w]*\[email protected]\w[-._\w]*\w\.\w{2,3})$ In your example the *actual* matched bit of text is: [email protected] NOT the full input string!

Title: I'm using Darren's...
Name: Nobody You Know
Date: 8/27/2003 8:43:36 PM
... in a slightly modified form (7-letter TLD max. vs. 3) because you don't have to be an ubergeek to make it work with JavaScript's replace() method. :)

Title: Kevin
Name: re-direct
Date: 8/14/2003 3:07:29 PM
There is/was another discussion going on. Looks like there are better ones out there.

Title: sorry but...
Name: Kevin
Date: 8/14/2003 2:32:24 PM
It won't match '[email protected]', I just tried. Here is the differences between yours and Mine. All domains must start and end with a-z or 0-9, the \w is equivelent to [A-Za-z0-9_] <-- as you can see there is an underscore in there, and domains and emails can't start or end with an underscore. Also ".com" extensions are always alpha-characters[a-z], and are between 2 to 4 chacaters long, such as .uk or .com. The 4 is there because I've heard(but not seen) that .info is going to be coming out soon. Mine will reject and yours will accept: [email protected]__ , [email protected] I wrote mine to be very strong, and yours in a little less strict. That is all I'm trying to say, I might reject a valid email, but I can't think of a valid one that would be rejected.

Title: RE: Better?
Name: Max Nokhrin
Date: 8/14/2003 11:05:17 AM
Yes, it's better because it doesn't allow for [email protected]

Title: It's not perfect however
Name: Ted Kerkelis
Date: 8/13/2003 4:15:06 PM
It allows [email protected]

Title: Better?
Name: Kevin
Date: 8/13/2003 10:30:49 AM
^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}$ I think this one is better, but thats just me, its just a little stronger rules

Copyright © 2001-2022, | ASP.NET Tutorials