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 

javascript special characters

solution:

escape backslashes on server before send over.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -