Created
October 3, 2013 21:43
-
-
Save pswaminathan/6817593 to your computer and use it in GitHub Desktop.
Regex for matching email addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^[\w.%+-]+@(?:[\w-]+\.)+[A-Za-z]{2,4}$ | |
Explanation: | |
^ # Start of string. If searching in-line replace with \b | |
[\w.%+-]+ # Matches alphanumeric, _, ., %, +, or - repeatedly | |
@ # name-domain separator | |
(?: | |
[\w-]+ # Matches alphanumeric or - repeatedly | |
\. # Matches dot in domain separator | |
)+ # Matches for one domain or for multiple subdomains | |
[A-Za-z]{2,4} # Matches top-level domain, no more than four characters | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment