【发布时间】:2016-06-10 06:25:18
【问题描述】:
如果给定字符串不在我的班级范围内,我想使用正则表达式从给定字符串中删除锚标记。
输入:
<p>Hi Hello <a href="#">World</a></p>. This is <div class="myclass">testing <a href="#">content</a>. some more content</div>. One more <a href="#"> Link </a>.
输出:
<p>Hi Hello </p>. This is <div class="myclass"> testing <a href="#">content</a>. some more content</div>. One more .
提前致谢。
【问题讨论】:
-
如果没有相同类型的嵌套标签,请尝试
(*SKIP)(*F)like this,但通常最好使用@Jan 提供的答案 Imho 之类的解析器。正则表达式在输入较大时会变得缓慢且不可靠。