[英]javascript replace closing table tag
I just want to add an </div>
after my table closing tag. 我只想在表格关闭标记后添加
</div>
。
var addDiv = addStyleSpacingTable.replace(/</table>/g, `</table></div>`)
in the above the /</table>/g
is the problem as it shows an parsing error, how do i get around this in js? 在上面的
/</table>/g
中,它是一个问题,因为它显示了解析错误,如何在js中解决呢?
reaplcing the table was easy as it has no escape paramater: 重新获得桌子很容易,因为它没有转义参数:
eg: var addDivTop = table1.replace( /<table>/g
, <div><table>
) 例如:var addDivTop = table1.replace(
/<table>/g
, <div><table>
)
Use a backslash (\\)
使用反斜杠
(\\)
let addStyleSpacingTable="<table></table>" var addDiv = addStyleSpacingTable.replace(/<\\/table>/g, `</table></div>`) console.log(addDiv)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.