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
(?s)(?:.?<row){99})(.?<row)
and I have the same result.
MY REQUEST
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:
(?s)(?:.?<row){99})(.?<row)
Try this regular expression:
(?s)(?:.*?<row){99}.*?\K<rowThe key part is the
\Ksyntax. 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<rowtext will be highlighted (i.e., selected) by Notepad++ after you do a Find.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login