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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$
Description
Matches a valid email address including ip's which are rarely used. Allows for a-z0-9_.- in the username, but not ending in a full stop i.e user.@domain.com is invalid and a-z0-9- as the optional sub domain(s) with domain name and a 2-7 char (a-z) tld allowing for short tld's like ca and new ones like museum.
Matches
username@domain.com | u-s_e.r1@s-ub2.domain-name.museum:8080 | user_name@123.123.123.12
Non-Matches
user@domain | user@domain.c | user.@domain.com
Author Rating: Not yet rated. nick bennett
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: - after @
Name: Marc
Date: 10/19/2011 10:28:41 AM
Comment:
It's possible to use a - after the @. Here is the correction: ^[\w-]+(\.[\w-]+)*@([a-z0-9]+[a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$


Title: VB
Name: kpeu3u
Date: 6/29/2011 6:46:20 PM
Comment:
This is the perfect code, just i add key sensitive :) Works great. Thanks! ^[\w-]+(\.[\w-]+)*@([A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*?\.[A-Za-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$


Title: VB
Name: kpeu3u
Date: 6/29/2011 6:39:03 PM
Comment:
This is the perfect code, just i add key sensitive :) Works great. Thanks! ^[\w-]+(\.[\w-]+)*@([A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*?\.[A-Za-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$


Title: Java Variation
Name: Thankful User
Date: 2/13/2008 11:48:15 AM
Comment:
^[a-z0-9-]+(.[a-z0-9-]+)*@([a-z0-9-]+(.[a-z0-9-]+)*?.[a-z]{2,6}|([a-b0-9-]{1,3}.){3}[a-b0-9-]{1,3})(:[a-b0-9-]{4})?$ Thanks for the code i found it worked, some slight changes made for use with java though!


Title: code ask
Name: Mercedes Parts Blog
Date: 3/21/2007 12:18:54 AM
Comment:
I'm not familiar with codes, just wanna ask if but something like this would do? <a href="http://www.mbpartswarehouse.com/mercedes_antenna.html">Mercedes antenna</a>


Title: Fails to match valid email address
Name: The Fred and Barney Comedy Team <fred&barney@stonehenge.com>
Date: 1/26/2005 3:21:52 AM
Comment:
Fails to match the valid email address fred&barney@stonehenge.com


Title: Error
Name: David van Leerdam
Date: 9/10/2004 7:10:33 AM
Comment:
It says 'murat@62.59.114.103.nl' is valid though it is definitely not.


Title: Domain name stuff
Name: Remi Sabourin
Date: 9/24/2003 1:27:58 AM
Comment:
Labels in domains can't start or end with hyphens. Example: blah@blah-.com shouldn't match. IP addresses should also appear in square brackets. An email like "blah"@blah.com is also possible. See RFC 2822 for email specification.


Title: Email validations
Name: DZ
Date: 4/30/2003 1:41:37 PM
Comment:
Nice, just add this to verify IP range -]+)*@(([0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5])|([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}| with a closing ) at the end. Here is the full code. ^[\w-]+(\.[\w-]+)*@(([0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5]\.[0-2]?[0-5]?[0-5])|([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$)


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