Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find nth instance of a string in Notepad++

I'm trying to use the regular expression functionality of Notepad++ to find every 99th instance of the string "ISA" in a text document. I tried to use the regex here, but I keep getting the following error: Error message

Any help would be much appreciated!

like image 729
Mason3k Avatar asked Sep 15 '16 05:09

Mason3k


1 Answers

You may enable . matches newline option, or just use an inline singleline/dotall modifier (?s):

(?s)(?:.*?ISA){98}

See the settings with the result of Find All in Current Document (with some 300 1 ISA lines):

enter image description here

If you want to replace the 98th occurrence of ISA with, say, USA, use (?s)((?:.*?ISA){97}.*?)ISA regex and use the $1USA as the replacement.

like image 97
Wiktor Stribiżew Avatar answered Oct 08 '22 05:10

Wiktor Stribiżew