1

So I got a text file with over 100000 lines to find and replace. Here is what I need to find:

>>DiskNum: 118
adfad
adfadf
adfadf
adfad
adafdd
>>FilePath: \\xxx\xxx\abc.tif

Replace with:

>>DiskNum: 118
adfad
adfadf
adfadf
adfad
adafdd
>>FullPath: C:\abc\abc.tif

The goal is to find >>DiskNum: 118 and the replace will happen on 6 lines after >>DiskNum: 118

Is there anyway to do it in notepadd++??

1
  • Perhaps write a perl script?
    – Ed Heal
    Commented Mar 18, 2017 at 8:11

1 Answer 1

2

Use the following regex:

Find What: (^>>DiskNum: 118(?:\R.*){5}\R>>FilePath:\h*).* Replace With: \1C:\\abc\\abc.tif Regular expression: CHECKED

Details:

  • (^>>DiskNum: 118(?:\R.*){5}\R>>FilePath:\h*) - Group 1 (referenced with \1 from the replacement pattern) capturing a sequence of:
    • ^ - start of a line
    • >>startoDiskNum: 118 - a literal char sequence
    • (?:\R.*){5} - 5 lines (\R is a line break, and .* matches any 0+ chars other than line break chars)
    • \R - line break
    • >>FilePath: - a literal char sequence
    • \h* - 0+ horizontal whitespaces
  • .* - the rest of the line

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.