Reputation: 358
This is my function,
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
JsLint Throws unescaped '[' in re declaration ! is there anything wrong with the construction of regex ?
Upvotes: 0
Views: 945
Reputation: 48807
In the first part of your regex ([^<>()[\]\\.,;:\s@\"]+
), you may need to escape the inner [
:
[^<>()\[\]\\.,;:\s@\"]+
^
This must be done in the next part of your regex as well.
Upvotes: 4