Seach a word and pick the 100th result
-
I search a word in my notefile and i find 15000 results now I want to locate where is the 100th result in my notefile. How can i detect it ?
-
@Tarık
may I direct you to this posting.
https://notepad-plus-plus.org/community/topic/16104/how-to-find-and-highlight-a-specific-occurance-of-a-symbolThe question there fits what you are trying to do. Have a go using that information. If in doubt come back to us with what you have tried and also an example of the data if possible. Real data/examples are ALWAYS so much better to help out posters.
Terry
-
Hi, @tarik, @terry-r and All,
From any starting point, in file, the generic regex
(?s)(?:.*?(X)){N}.*?\K\1will find theNth occurrence of X, where X can be, either :-
A simple character
-
A word => The regex
\b<Word>\b -
A string of characters
-
A regular expression
For instance, the regex
(?s)(?:.*?(\bthe\b)){9}.*?\K\1would find, from current location, the10thoccurrence of the articletheCheers,
guy038
-
-
@guy038 said:
(?s)(?:.?(\bthe\b)){9}.?\K\1
Thank you for kindly answers. I don’t know where can I use this command in notepad++.
-
- Move your caret/cursor to the place where you want to start seeking the Nth match from
- Invoke the Find dialog by pressing ctrl+f
- Select Regular expression as the Search mode
- Put an expression such as @guy038 's in the Find what zone
- Tick the Match case checkbox if you want to…umm…only match the case of your text in the Find what
- Press Find Next button
Does that make it clear?
-
Thank you all!
-
Hi, @tarik, @scott-sumner, @terry-r and All,
Thanks, Scott, for your additionnal information. Look like I was a bit tired to develop ;-))
Of course, as Scott mentioned, your can, either, perform a sensitive to case OR a insensitive to case search, with the respective generic regexes :
-
(?s-i)(?:.*?(X)){N}.*?\K\1( Sensitive ) -
(?si)(?:.*?(X)){N}.*?\K\1( Insensitive )
Cheers,
guy038
-
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