I have a regex string that is getting passed into to my code, when I try to inject it into the RegExp object constructor, the RegExp object appears to be adding characters.
original string regex:
/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/
After calling new RegExp(mystring); results in the following:
regex:
/\/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$\//
I can't hardcode the string in my js file, so I need a way to make this work.