我有 2 个段落,带有 html 标签<p class="mb-40px"></p>
此标签内有文本和另一个 <p..> 标签
我需要查找并删除主标签中包含的 html 标签<p class="mb-40px"></p>
例子:
<p class="mb-40px">Miracles every day <p lang="ro-RO" align="JUSTIFY">being at la home, the poet Petru Iliesu made an international appeal to condemn the killing of demonstrators, shot on the streets of town.</p>
<p class="mb-40px">The pleasure we feel after reading a book is different from the pleasure of tasting a dish <p class="dis23">. In the first case, pleasure is disinterested, having no particular purpose, as a release from external preoccupations.</p>
输出
<p class="mb-40px">Miracles every day being at la home, the poet Petru Iliesu made an international appeal to condemn the killing of demonstrators, shot on the streets of town.</p>
<p class="mb-40px">The pleasure we feel after reading a book is different from the pleasure of tasting a dish. In the first case, pleasure is disinterested, having no particular purpose, as a release from external preoccupations.</p>
我的正则表达式不太好:
寻找: (?:<p class="mb-40px">|\G)\S*\K(?:\h+<\s*(\w+)[^/>]*>)(?=.*</p>)
替换为:(留空)
答案1
答案2
是的,我设法自己找到解决方案:
寻找:(?-i:<p class="mb-40px">|\G(?!^))(?s:(?!</p>).)*?\K(?-i:<\s*(\w+)[^/>]*>)
替换为:LEAVE EMPTY
因此,如果我想查找/替换其他两个部分中的内容,通用正则表达式将是:
(?-i:REGION-START|\G(?!^))(?s:(REGION-FINAL).)*?\K(?-i:FIND REGEX)