javascript - String to regular expression -
i regular expression string server. example
js_pattern = "/^9\d+$/"
and need string same regular expression (without modifications)
js_regexp = /^9\d+$/
re = new regexp(js_pattern)
doesn't work me because in case /\/^9d+$\//
are there correct variants convert string regular expression in javascript?
any non-special character gets evaluated character in string.
for example
// true, because it's non-special gets evaluated character. console.log("\a" === "a"); // true // false, because it's new line special character. console.log("\n" === "n"); // false
solution:
escape backslashes on server before send over.
Comments
Post a Comment