Created
March 16, 2015 13:14
-
-
Save nkcmr/0ff9713f7ff1851be991 to your computer and use it in GitHub Desktop.
best working email regex for javascript [updated]
This file contains hidden or 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
/** | |
* i say updated because previously, the regex wouldn't | |
* like if you entered, '[email protected]', which with | |
* recently added TLDs is a perfectly valid email address. | |
* So i looked up the maximum length for a TLD (which is | |
* 63 characters), and put it in here. Now it works pretty well. | |
* It even acceptes those GMail aliases ([email protected]) | |
*/ | |
var EMAIL_REGEX = /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.({2,63})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment