Skip to content

Instantly share code, notes, and snippets.

@ChrisLTD
Last active January 4, 2016 04:09
Show Gist options
  • Save ChrisLTD/8566361 to your computer and use it in GitHub Desktop.
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.
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