我正在寻找一个正则表达式来匹配 XML 文档中的注释:
<root> <!-- match this --> <but>not this</but> <!-- and also this --> </root>
我试过<!--[^(-->)]*-->,它只匹配单行注释,<!--[\s\S\n]*-->也匹配非注释节点。
<!--[^(-->)]*-->
<!--[\s\S\n]*-->
regex
regex ×1