【发布时间】:2017-06-15 02:56:22
【问题描述】:
我的文字是
<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引用此代码
【问题讨论】:
标签: javascript regex