I've already checked the Mozilla website and W3schools, but I can't seem to find the solution.
var modifyString = function (string1, string2)
{
if (string2.match(string1))
{
string1 = new RegExp(string1);
string2 = string2.replace(string1, "XXX");
return string2;
}
return null;
};
modifyString("dog", "dogeatdog");
Now, I need to adjust the above RegExp to apply globally, but I'm unsure where or how to include the g
character so that the function call above returns XXXeatXXX
.
Any assistance on this matter would be greatly appreciated!