/variable/ in regular expression in javascript code example
Example: javascript use variable regex
// CREATE A REGEXP object
var replace = "regex";
var re = new RegExp(replace,"g");
//then use
"mystring".replace(re, "newstring")
// CREATE A REGEXP object
var replace = "regex";
var re = new RegExp(replace,"g");
//then use
"mystring".replace(re, "newstring")