How to delete every third line in Notepad ++?

I have text in the following lines:

tom
tim
john
will
tod
hello
test
ttt
three

I want to delete every third row using the above example, which I want to delete: john,hello,three

I know this requires some regular expression, but I'm not the best with it!

What I tried:

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

The others I tried were just trying with help \n\retc. Again, not the best with regex. The above attempt, I thought, was close.

+4
source share
4 answers

gedit ubuntu

Search: (.*?)\n(.*?)\n(.*)\n
Replace with:\1\n\2\n

+6
source

This will delete every third line, which may contain more than one word.

  • Ctrl + H
  • Find what: (?:[^\r\n]+\R){2}\K[^\r\n]+(?:\R|\z)
  • Replaced by: 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

:

tom
tim
will
tod
test
ttt

:

enter image description here

+3

OP , Sahil " ", , ++ . Sahil Toto .

Sahil: (.*?)\n(.*?)\n(.*)\n 79 *, \n; 112 .
.

: ((?:[^\r\n]+\R){2})[^\r\n]+\R 39 *, \n; 173 . .

25 . , , - , , :

\S+\s+\S+\s+\K\S+\s*

.

\S

\S " "
+
*
\K ,

* \S 3 . , , .

, , , .

+1

, ConyEdit . cc.dl 3.3 , 3 .

0

Source: https://habr.com/ru/post/1670405/


All Articles