var str = "1405199610";
var re = new RegExp("\d{10}");
var myArray = re.test(str);
myArray gives false!
How is this possible? I tested this with online regex checkers and it checks out ok. When i try it in the console or jsfiddler, it doesn’t work. Am I missing something?
you need to escape the
\when regexp is created byRegExp()objectSee MDN reference