-1
我想从字符串中替换所有字符的存在,但它不起作用。这里是我的代码:如何从jquery中的字符串替换所有字符的存在?
$.each(jsonArray, function (fromString, jtm) {
// tempString = tempString.replace(jtm.from, jtm.to)
tempString = tempString.replaceAll(jtm.from, jtm.to);
});
我检查使用全局全部更换为Told in this article,但我没有得到我怎么能在我的代码实现。
请帮帮我。
'tempString = tempString.replace(新正则表达式(jtm.from, 'G'),jtm.to)'' –
= tempString tempString.replace(新正则表达式(JTM。 from.replace(/ [| \\ {}()[\]^$ + * ..]/g,'\\ $&'),'g'),jtm.to)' –
@downvoters,please comment –