I was reading my O'Reilly JavaScript The Definitive Guide when I came
across RegExp and thought I could tighten up my JavaScript code that
checks for a valid email address. Why does the following not appear to work:
var email_address = "Joe@Schmoe";
var email_regex = new RegExp ("^(\\w+)(\@)(\\w+)(\.)(\\w+)$");
var result = email_regex.exec (email_address);
alert (" result[1] = \"" + result[1] + "\"\n" +
" result[2] = \"" + result[2] + "\"\n" +
" result[3] = \"" + result[3] + "\"\n" +
" result[4] = \"" + result[4] + "\"\n" +
" result[5] = \"" + result[5] + "\"");
The resulting alert box contains:
result[1] = "Joe"
result[2] = "@"
result[3] = "Schm"
result[4] = "o"
result[5] = "e"
It appears that the "\." is not escaping the "." to mean the literal
period. What am I doing wrong?
--
How come you don't ever hear about gruntled employees? And who has been
dissing them anyhow?