如何在javaScript中将{0}定义为正则表达式

如何在javaScript中将{0}定义为正则表达式,javascript,jquery,Javascript,Jquery,我使用下面的正则表达式模式和它的工作罚款 temp.replace(new RegExp(/\{1\}/g), +row.cells[0].innerText); 但现在我想让模式动态化,但它不起作用 for (i = 0; i < row.cells.length; i++) { temp = temp.replace(new RegExp("/\{"+i+"\}/g"), +row.cells[0].innerText); } for(i=0;i

我使用下面的正则表达式模式和它的工作罚款

temp.replace(new RegExp(/\{1\}/g), +row.cells[0].innerText);
但现在我想让模式动态化,但它不起作用

for (i = 0; i < row.cells.length; i++) {
     temp = temp.replace(new RegExp("/\{"+i+"\}/g"), +row.cells[0].innerText);
}
for(i=0;i
let strings=[“bli”、“bla”、“blueh”、“foo”、“bar”];
设temp=“{1}{2}{3}{4}{5}{6}”;
对于(i=0;i
let strings=[“bli”、“bla”、“blueh”、“foo”、“bar”];
设temp=“{1}{2}{3}{4}{5}{6}”;
对于(i=0;i控制台日志(temp)字符串有自己的转义,你需要在
RegExp
构造函数中双重转义。我尝试了这么多的组合,你能帮忙吗。但是请不要告诉我它的类型是@
+行。单元格[0]。innerText
有什么问题吗问题是regex,我在尝试
“/\{+I+\}/g”
字符串有自己的转义,你需要在
RegExp
constructor中进行双重转义。我尝试了很多组合,你能帮我一下吗。但是请不要告诉我它的类型@
+行。单元格[0]。innerText
有什么问题吗问题是regex,我在尝试
“/\{+I+“\}/g”