I\'ve got a situation where I want to get a regexp from the user and run it against a few thousand input strings. In the manual I found that the RegExp
object h
You have to compile your regex first to use it if you are using /
, try this out:
var regex=new RegExp('/[a-zA-Z]/')
console.log("not compiled with escape /", regex.test("ciao") )
regex.compile()
console.log("compiled", regex.test("ciao") )
var regex=new RegExp('[a-zA-Z]')
console.log("not compiled, but no escape /", regex.test("ciao") )