Page 1 of 1

How to delete 270 lines?

Posted: Thu Apr 22, 2010 4:59 pm
by grevesz
Hello,

What is the regular expression to find and delete 270 lines (no matter what the content) starting at a line that follows a certain expression?

Example:
If the expression is APPLE and its first occurrence is on line 500 (doesn't matter if there are other characters in that line or not), then I want to delete lines 501-770 (270 lines starting with the following line).

Thanks in advance!

Gabor

Posted: Thu Apr 22, 2010 6:08 pm
by MudGuard
The Regex would be:

Code: Select all

.*APPLE(.*\n){270}
Make sure the ". matches end of line" modifier is OFF.

(Note: this expression does NOT work in Textpad)

Posted: Thu Apr 22, 2010 6:29 pm
by ben_josephs
The OP wants to keep the line with APPLE on it. And I believe you have to handle Windows line endings (CR,LF) explicitly.
Search for: (.*APPLE.*\r?\n)(.*\r?\n){270}

[X] Regular expression
[ ] "." matches end of line characters [i.e., not selected]

Replace with: $0

[ ] Literal replacement [i.e., not selected]

Posted: Thu Apr 22, 2010 6:41 pm
by grevesz
Thanks!
:D

Gabor