我的文字是
<DIV STYLE="text-align:Left;font-family:Segoe UI;font-style:normal;font-weight:normal;font-size:12;color:#000000;"><P STYLE="font-family:Arial;margin:0 0 0 0;"><SPAN STYLE="font-family:Segoe UI;"><SPAN>{firstname} will continue to learn high frequency words, try to remember words and us them in their writing. {firstname} always uses correct spacing in their writing and attempts to use punctuation.</SPAN></SPAN></P></DIV>
所以现在我想用 {firstname_C}
替换索引 202 的 {firstname}我的代码不起作用
var endIndex = 202;
var pattern = new RegExp("({firstname}{" + endIndex + "})", "g");
commentString = commentString.replace("({firstname})/g", "{firstname_C}");
从here
引用此代码答案 0 :(得分:0)
gallery.html
和contact.html
是regexp中的特殊字符,您必须以模式转义它们:
尝试:
{