Reputation: 697
I'm trying to validate email addresses in javascript, I tried this
/[A-Za-z0-9_\-]+\@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+/
but it matched the input "b@aaa", where the middle "a" letter should be a dot to match. and tried not to escape the dot like this:
/[A-Za-z0-9_\-]+\@[A-Za-z0-9_\-]+.[A-Za-z0-9_\-]+/
and it matched the input too.
Upvotes: 0
Views: 1587
Reputation: 5597
I think you need 2 backslashes:
/[A-Za-z0-9_\-]+\@[A-Za-z0-9_\-]+\\.[A-Za-z0-9_\-]+/
Upvotes: 1