Mason3k
Mason3k

Reputation: 181

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!

Upvotes: 8

Views: 5531

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626758

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.

Upvotes: 9

Related Questions