Title |
Test
Find
Pattern Title
|
Expression |
^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$ |
Description |
This expression matches email addresses, and checks that they are of the proper form. It checks to ensure the top level domain is between 2 and 4 characters long, but does not check the specific domain against a list (especially since there are so many of them now). |
Matches |
joe@aol.com | joe@wrox.co.uk | joe@domain.info |
Non-Matches |
a@b | notanemail | joe@@. |
Author |
Rating:
Not yet rated.
Steven Smith
|
Source |
|
Your Rating |
|
Title: Special character in first half of email address
Name: Neola
Date: 7/13/2015 6:57:13 AM
Comment:
^([\w\W][^@]+)\@([\w-]+\.)+[\w-]{2,4}$
modified regex for email address having some+name@server.domain.com ('+')
Title: special character in domain name
Name: zikwag
Date: 7/17/2009 2:45:41 PM
Comment:
how can i modify this regex so that the address xyz@its.j&j.com bypass validation rules
Title: special character in domain name
Name: zikwag
Date: 7/17/2009 2:06:30 PM
Comment:
how can i modify this regex so that the address xyz@its.j&j.com bypass validation rules
Title: Further refined
Name: cottsak
Date: 1/4/2007 11:09:29 PM
Comment:
the following is modded further from the comments on this page. it additionally:
- does not allow underscore in the domain name
- does not allow hyphen at start or end of domain name (sub-domains included)
also, i have expand the \w change so that it's explicit, irrespective of engine flavour
the only other thing i didn’t factor (that i could think of) was minimal number of characters for a domain. generally this is >= 2 but for sub-domains it may be 1 so i left it. it would also make the expression a lot more complicated.
^[-a-zA-Z_0-9.]+@([a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z0-9])?.)+[a-zA-Z]{2,4}$
Title: \. inside a character class does not mean .
Name: Udo Güngerich
Date: 8/14/2006 2:42:10 AM
Comment:
Inside character classes . does not have a special meaning, so you do not need to escape it!
Regards,
Udo
P.S.: [[:alnum:]_-\.] must of course be [-[:alnum:]_\.] else the dash tries to be a range and fails ;)
Title: [\w] is not a character class according to Perl 5.8.6
Name: Udo Güngerich
Date: 8/14/2006 2:37:23 AM
Comment:
So [\w-\.] is probably better written as [[:alnum:]_-\.] (with POSIX character classes)
Regards,
Udo
Title: little improvement
Name: Jocker
Date: 7/10/2006 11:25:32 AM
Comment:
^[\w-\.]+@(?:[\w-]+\.)+[a-zA-Z]{2,4}$
a slightly better version: this one does not capture part of the domain, does not allow numbers in the regional code
Title: Incompatible with internet standards
Name: Josh Jore
Date: 2/23/2004 11:34:04 AM
Comment:
The expression does not account for whitespace or quoting in the mailbox portion of the address and neglects to handle quoted domains.
Title: FLANTUS
Name: SGSGS
Date: 1/22/2004 5:14:13 PM
Comment:
THANKS A LOT! EXELLENT SITE ESPECIALLY TO THE STARTERS. IT IS ALSO GREAT FOR LOOKUP.
THANKS