我已经看过Mozzila网站和W3schools但找不到答案
var someFunction = function (someString, someOtherString)
{
if (someOtherString.match(someString))
{
someString = new RegExp(someString);
someOtherString = someOtherString.replace(someString, "XXX");
return someOtherString;
}
return null;
};
someFunction("dog", "dogeatdog");
现在我希望上面的RegExp应用全局,但我不知道在哪里/如何添加g
字符,以便上面的函数调用返回XXXeatXXX
任何帮助将不胜感激!