Last active
January 4, 2016 04:09
-
-
Save ChrisLTD/8566361 to your computer and use it in GitHub Desktop.
Regex for minimally testing valid email addresses. Looks for some characters, @ symbol, some characters, a period, then some more characters.
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
var regex = /^.+@.+\..+$/; | |
var tests = Array( '[email protected]', 'testATtest.com', 'test@testDOTcom', | |
'[email protected]', '[email protected]', '[email protected]'); | |
for(var i = 0; i < tests.length; i++){ | |
var result = regex.exec( tests[i] ); | |
console.log('Testing: ' + tests[i]); | |
if( result ){ | |
console.log('match found\n'); | |
} else { | |
console.log('no matches\n'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment