如何删除Notepad ++上的每三行?

Wil*_*iam 4 regex notepad++

我在新行上有文字,如下:

tom
tim
john
will
tod
hello
test
ttt
three
Run Code Online (Sandbox Code Playgroud)

我想删除每个第三行,所以使用上面的例子我要删除: john,hello,three

我知道这需要一些正则表达式,但我不是最好的!

我尝试了什么:

Search: ([^\n]*\n?){3} //3 in my head to remove every third
Replace: $1
Run Code Online (Sandbox Code Playgroud)

我试过的其他人只是尝试\n\r等等.再次,不是最好的正则表达式.我认为上述尝试有点接近.

Tot*_*oto 9

这将删除每三行可能包含多个单词的行。

  • Ctrl+H
  • 找什么:(?:[^\r\n]+\R){2}\K[^\r\n]+(?:\R|\z)
  • 用。。。来代替:LEAVE EMPTY
  • 检查环绕
  • 检查正则表达式
  • Replace all

解释:

(?:             # start non capture group
  [^\r\n]+      # 1 or more non linebreak
  \R            # any kind of linebreak (i.e. \r, \n, \r\n)
){2}            # end group, appears twice (i.e. 2 lines)
\K              # forget all we have seen until this position
[^\r\n]+        # 1 or more non linebreak
(?:             # start non capture group
  \R            # any kind of linebreak (i.e. \r, \n, \r\n)
 |              # OR
  \z            # end of file
)               #end group
Run Code Online (Sandbox Code Playgroud)

给定示例的结果:

tom
tim
will
tod
test
ttt
Run Code Online (Sandbox Code Playgroud)

屏幕截图:

在此输入图像描述

演示


Sah*_*ati 6

gedit ubuntu

搜索:(.*?)\n(.*?)\n(.*)\n
替换为:\1\n\2\n