I do have the following string:
"/^\d{4}$/"
which I want to convert to a RegExp to use the test method on it. However, simply doing :
var r = new RegExp("/^\d{4}$/") // returns : /\/^\d{4}$\//
r.test("4800") // returns false
isn't working.
I also tried the following :
var r = /^\d{4}$/
r.test("4800") // returns true
which is working
What am I missing here ? How to have it working in the first case with a string.