I have the following function, but my string is never replaced? What am I doing wrong?
function customRegex(){
return function(myString,replacement,myValue){
var s = myString;
var rgx = new RegExp("/("+replacement+")/,gi");
myString = myString.replace(rgx, myValue);
return myString;
}
}
var reg = customRegex();
console.log( reg("This is the worst!","worst","best"));
//This is always returning the original string?