<p class="mb-40px">Decisive too, of
<p class="mb-40px">otherwise, it was the opportunity to
<p class="mb-40px">acquire what were to be two pillars
<p class="mb-40px">fundamentals of his intellectual formation:
<p class="mb-40px">Latin and virtually none of the Greek
<p class="mb-40px">written down, they were the subject of daily commentary on Apollo.</p>
必须成为:
<p class="mb-40px">Decisive too, of otherwise, it was the opportunity to acquire what were to be two pillars fundamentals of his intellectual formation: Latin and virtually none of the Greek written down, they were the subject of daily commentary on Apollo.</p>
我的正则表达式不是很好:
寻找: (<p class="mb-40px">)(.*?\s+\n)[\s\S]*?</p>
替换为: \1$0\3
答案1
答案2
- Ctrl+H
- 找什么:
([^>])\s+(<p class="mb-40px">)
- 用。。。来代替:
\1\x20
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Replace all
答案3
正则表达式无法连接可变数量的行,这比正则表达式更适合编程语言。
我的解决方案需要一次连接两行,因此您需要根据需要多次执行“全部替换”,直到替换失败。
这是复杂的搜索字符串:
查找内容:^<p class="mb-40px">(.*(?<!p>))\R^<p class="mb-40px">(.*?(?<!p>))$
替换为:<p class="mb-40px">\1 \2
搜索模式: 没有“。”的正则表达式匹配换行符。
要了解其工作原理,请参阅 regex101。
参考 : 不以给定后缀结尾的字符串的正则表达式。