I am sure its something pretty small that I am missing but I haven\'t been able to figure it out.
I have a JavaScript variable with the regex pattern in it but I can
Backslashes are special characters in strings that need to be escaped with another backslash:
var value = "someone@something.com"; var pattern = "^\\w+@[a-zA-Z_]+?\\.[a-zA-Z]{2,3}$" var re = new RegExp(pattern); re.test(value);