ENHANCEMENT - select ONLY X nth occurence of String using REGEX

  • Hello,

    One month ago I searched a Regex expression to find the X nth occurence of a String in a XML file.

    On the web, I have found this expression (?s)(?:.*?<row){100} that search the 100 nth occurence of the string “<row”

    The problem with Notepad is that it does’nt display/select the 100 nth occurence but all the occurence from 1 to 100 !

    I have tested the following Regex expression using ONLY GROUPING (begin with ?:) expression and a final CAPTURING expression


    and I have the same result.


    I want that if I give the previous Regex search expression that notepad display/select only CAPTURED part !

    It is certainly easy to implement when there are only one capture string !

    Can somebody implement this enhancement in Notepad++ ?

    Another approach would be to add a numeric input field in which the user can specify the number of occurence to find !

    Best regards

  • @Bernard-Schleich said:


    Try this regular expression:

    The key part is the \K syntax. It tells the regular expression engine to match but don’t include in the resultant match anything that comes before it. Thus, in the example above, only your desired <row text will be highlighted (i.e., selected) by Notepad++ after you do a Find.

Log in to reply