在多行中查找并加入行

时间:2019-09-24 08:21:48

标签: notepad++

我想选择以handleSubmit(event) { event.preventDefault(); let target = event.target; let formData = {}; for (let i = 0; i < target.length; i++) { formData[target.elements[i].getAttribute("name")] = target.elements[i].value; } console.log('formData', formData); } <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.

我正在使用RegEx <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. ,但只标记了一行。

1 个答案:

答案 0 :(得分:0)

  • Ctrl + H
  • 查找内容:(<h2>)\R(.+)\R(.+)
  • 替换为:\1\2\3
  • 检查环绕
  • 检查正则表达式
  • 全部替换

说明:

(<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,这没有任何意义。