我有这个 html 标签 <p class="text_obisnuit2"></p>
在这个标签中有一些单词(其他标签),例如<strong>
或</strong>
。还有<em>
或</em>
例子:
<p class="text_obisnuit2"><strong><em> My name is love. </em><strong></strong></p>
我想删除所有<strong>
和</strong>
特定的<p class="text_obisnuit2"></p>
所以输出应该是:
<p class="text_obisnuit2"><em> My name is love. </em></p>
答案1
- Ctrl+H
- 找什么:
(?:<p class="text_obisnuit2">|\G(?!^)).*?\K</?strong>(?=.*?</p>)
- 用。。。来代替:
LEAVE EMPTY
- 取消选中 相符
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Replace all
解释:
(?: # non capture group
<p class="text_obisnuit2"> # literally
| # OR
\G # restart from last match position
(?!^) # if not at the beginning
) # end group
.*? # 0 or more any character
\K # forget all we have seen until this position
</?strong> # <strong> OR </strong>
(?=.*?</p>) # positive lookahead, make sure we have </p> after
截图(之前):
截图(之后):