Insert 2 lines after every 5th occurence of string

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
steve1040
Posts: 39
Joined: Fri Oct 13, 2006 2:19 am

Insert 2 lines after every 5th occurence of string

Post by steve1040 »

I have a text file with 15000 rows (See sample below)

How can I insert 2 lines after every 5th instance of the word "ENTER"

I need to insert the a new line with the word "ENTER" and a second line with the string "DELAY 35000"

Thanks

  • DELAY 5000
    CODE: 1234
    ENTER
    DELAY 500
    CODE: 0000
    ENTER
    DELAY 500
    CODE: 1111
    ENTER
    DELAY 500
    CODE: 2580
    ENTER
    DELAY 500
    CODE: 1212
    ENTER
    DELAY 500
    CODE: 5555
    ENTER
    DELAY 500
    CODE: 2222
    ENTER
    DELAY 5000
    CODE: 1234
    ENTER
    DELAY 500
    CODE: 0000
    ENTER
    DELAY 500
    CODE: 1111
    ENTER
    DELAY 500
    CODE: 2580
    ENTER
    DELAY 500
    CODE: 1212
    ENTER
    DELAY 500
    CODE: 5555
    ENTER
    DELAY 500
    CODE: 2222
    ENTER
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Search | Replace... (<F8>):
Find what: ([\s\S]*?ENTER){5}
Replace with: $0\nENTER\nDELAY 35000

[X] Regular expression

Replace All
Note: [\s\S] matches any character that is white space or is not white space, that is, any character at all, including a newline (which . does not match).
Post Reply