A literal /pattern/only works as a literal. Not inside the line.
If you want to use a string pattern to create a regular expression, you need to create a new RegExp object:
var re = new RegExp(pattern_1)
And in this case, you lower the closing front legs ( /). These two lines are equivalent:
var re = /abc/g;
var re = new RegExp("abc", "g");
source
share