首页 > 解决方案 > 查找并连接多行中的行

问题描述

我想选择以 and 结尾的行<h2></h2>并希望加入这些行,如下所示:

现有文本:

<h2>
A musician's tattoo
</h2>

If you’ re a musician and would like tolket a tattoo, get a tattoo of your ...

<h2>
A zombie hare chest tattoo
</h2>

100/lO0.002.jpg
You won’ tsee this tattoo every day.

<h2>
Abby Name Tattoos
</h2>

For your little angels, a tattoo of their names will never be a mistake.

所需文字:

<h2>   A musician's tattoo   </h2>

If you’ re a musician and would like tolket a tattoo, get a tattoo of your ...

<h2>   A zombie hare chest tattoo   </h2>

100/lO0.002.jpg
You won’ tsee this tattoo every day.

<h2>   Abby Name Tattoos   </h2>

For your little angels, a tattoo of their names will never be a mistake.

我正在使用 RegEx <h2>*?.*?</h2>,但只标记了一行。

标签: notepad++

解决方案


  • Ctrl+H
  • 找什么:(<h2>)\R(.+)\R(.+)
  • 用。。。来代替:\1\2\3
  • 检查环绕
  • 检查正则表达式
  • Replace all

解释:

(<h2>)  : <h2> into group 1
\R      : any kind of linebreak
(.+)    : matches any character into group 2 (except for line terminators)
\R      : any kind of linebreak 
(.+)    : matches any character into group 3 (except for line terminators)

如果您真的想在H2文本前后插入空格,则必须\2在替换为之前和之后执行此操作。对于干净的 HTML,这是没有意义的。


推荐阅读