【发布时间】:2019-12-08 07:58:08
【问题描述】:
我有下面的正则表达式,
const regex = new RegExp('<(.*)>' + text + '<(.*)>');
renderer.setProperty(node, 'innerHTML', node.innerHTML.replace(regex, '<$1>' + replaceText + '<$2>'));
我需要使用'<$open>'和'<$close>',而不是使用'<$1>'和'<$2>'
当我尝试更改时,它没有按预期工作。
怎么做?
【问题讨论】:
-
$open和$close是什么意思? -
new RegExp('<(?<open>.*?)>' + text + '<(?<close>.*?)>')和'<$<open>>' & '<$<close>>'替换 -
完美。谢谢
标签: javascript regex typescript