I have been attempting to verify the format of an email address using the script below, but I seem to be making a mistake somewhere. When I try to match the reg_1
pattern with str_1, str_2, str_3
, I consistently get a false result. Can anyone help me understand why?
var reg_1 = /^[a-zA-Z][0-9_.][@]{1}[a-zA-Z0-9][.]{1}[a-zA-Z0-9]$/;
var id_1 = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2152544940484d4654515540111261464c40484d0f424e4c">[email protected]</a>";
var id_2 = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3a5d4f4a4e5b14494f525b53567a485f5e535c5c14595557">[email protected]</a>";
var id_3 = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e390968b828a8fbc8496939782d3d0a38c958acd808c8e">[email protected]</a>";
document.write(reg_1.test(id_1));
document.write("<br / >" + reg_1.test(id_2));
document.write("<br / >" + reg_1.test(id_3));