说我有很多文件,可以在其中看到与以下内容类似的结构:
<li><p>text.</p><p>some other text.</p></li>
这不是我想要的。我想要以下内容:
<li>text.<p>some other text.</p></li>
我知道如何找到这样的实例(<li><p>.*</p> <p>.*</p></li>
),但是我不知道如何替换它们,而是保持内容不变。
甚至有可能吗?
答案 0 :(得分:1)
(<li>)<p>(.+?)</p>
$1$2
说明:
(<li>) # group 1, open <li> tag
<p> # open <p> tag
(.+?) # group 2, 1 or more any character, not greedy
</p> # close </p> tag
替换:
$1 # content of group 1 (<li>)
$2 # ccontent of group 2 (text.)
屏幕截图(之前):
屏幕截图(之后):
答案 1 :(得分:0)
对于我的用例
Find what: <li><p>(.*?)</p><p>(.*?)</p></li>
Replace with: <li>\1<p>\2</p></li>
Match Case: checked
Regular expression: checked
.matches newline: check