delete previous and 3 following lines

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
osiftp
Posts: 2
Joined: Thu Jul 16, 2009 9:16 am

delete previous and 3 following lines

Post by osiftp »

Hello,

I have a file of about 40000 lines, it is composed of a blank line than 5 lines of text than a blank line and 5 lines..... always the same pattern.
In the second line of text, I need to locate a string of characters ( always the same ), if found I need to delete the line, the previous line and the next 3 ones. Is there a way to delete the Previous line ?

pattern as follows:

blank line
line1 hgtrefde hrterfde uyhrfrsg yrhtgreerdefd yrhgfd
line2 ujyhg rtgfr rtgf ABCDEF tyhrtgfer ythgf utyhg
line3 uythrgf yhtrgd grezrrzg ryrthg terg 'ehg tregf rer
line4 ythrtgrteg vfc rtg teg trg rteg rtg
blank line
If I find ABCDEF in line2 I need to delete line1/line2/line3/line4
otherwise do nothing

Thank you for your help
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Your description is inconsistent with your example. Assuming the description is correct:
Find what: ^\n.+\n.*ABCDEF.*\n.+\n.+\n.+\n
Replace with: \n

[X] Regular expression

Replace All
osiftp
Posts: 2
Joined: Thu Jul 16, 2009 9:16 am

Post by osiftp »

great, this is what I was looking for.

Thank you for the quick answer.
Post Reply