Reputation: 7606
regexp = new RegExp(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b);
Error:66SyntaxError: Unrecognized token '\'
Upvotes: 1
Views: 1005
Reputation: 758
I think the regex should be:
/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/
Upvotes: 0
Reputation: 270775
When calling new RegExp()
you must pass the pattern as a string. Enclose it in quotes.
var regexp = new RegExp('\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b');
You could also create it as using the special /pattern/
delimited syntax, in which it is not quoted:
var regexp = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/;
Upvotes: 5