K
K
ka1enka2015-03-04 19:27:40
Regular Expressions
ka1enka, 2015-03-04 19:27:40

How to delete every nth lines in a file using notepad++?

Since I don't understand regular expressions at all, I ask for help.
There is an example solution stackoverflow.com/questions/23875234/deleting-ever...
([^\r\n]*\R)[^\r\n]*\R?
It is suitable for every second line, but it must be deleted from the second to the fifth. Those. the first remains, 2, 3, 4, 5 - are deleted, the sixth remains, 7, 8, 9, 10 - are deleted, 11 - remains.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
localghost, 2015-03-04
@ka1enka

In theory, it should be enough to simply repeat the second part four times:
([^\r\n]*\R)[^\r\n]*\R[^\r\n]*\R[^\r\n ]*\R[^\r\n]*\R?
or, folding three:
([^\r\n]*\R)([^\r\n]*\R){3}[^\r\n]*\R?
Only this will "break" at the end if the number of lines is not a multiple of five - the last block of less than five lines will not be found by this expression (and I can't figure out if it can be improved).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question