Javascript 正则表达式无效组

Javascript 正则表达式无效组,javascript,regex,Javascript,Regex,有人知道为什么会出现无效正则表达式:Invalid group错误吗 text.replace(/(?<!br|p|\/p|b|\/b)>/g, "&gt;"); text.replace(/(?/g,”); 这个没问题: text.replace(/<(?!br|p|\/p|b|\/b)/g, "&lt;"); text.replace(/JavaScript不支持lookbehinds。以下是获得相同行为的一种方法: text = text.repla

有人知道为什么会出现
无效正则表达式:Invalid group
错误吗

text.replace(/(?<!br|p|\/p|b|\/b)>/g, "&gt;");
text.replace(/(?/g,”);
这个没问题:

text.replace(/<(?!br|p|\/p|b|\/b)/g, "&lt;");

text.replace(/JavaScript不支持lookbehinds。以下是获得相同行为的一种方法:

text = text.replace(/(br|p|\/p|b|\/b)?>/g, function($0, $1){
    return $1 ? $0 : "&gt;";
});
此方法来自以下博客条目:

这里是一个更新的