Search++: A work in progress
-
Do you think it would be possible to add this feature to Search++ as part of the plugin’s future development ?
I do think it would be possible, and that it would be a useful enhancement.
I haven’t studied the problem in detail yet. The relevant concepts exist and are well-defined: Unicode canonical equivalence and compatibility equivalence. Probably someone has already implemented practical searches using canonical and compatibility equivalence in open source code, so finding and studying existing, mature solutions that have already encountered and resolved whatever complications inevitably arise will no doubt be my first step.
-
-
Hello, @coises, @thomas-knoefel and All,
For some obscure reasons, one day, my usual
USBkey for tests was just considered as containingRAWtext. I did not even succeeded to reformat it ! So I threw it in the trash and from a ( not too old ) copy of that key, I was able more or less, to reconstruct the original contents of thisUSBdrive !
Now, when I asked Google about “softwares able to search canonical and compatibility Unicode characters”, the IA answer, at the beginning, proposed, among other things, the CLI software
ripgrep (rg). Although it does not seem to really treat canonical and compatibility Unicode forms AFAIK, it is quite fast and has plenty of interesting options !Refer to https://github.com/BurntSushi/ripgrep. The last release is version
16.0. Download, preferably, theripgrep-16.0.0-x86_64-pc-windows-msvc.ziparchive which is compatible with64-bit Windows11laptopsAfter extraction of the
rg.exesoftware, in a CMD window, runrg -hfor short descriptions orrg --helpfor more details !
Following my usual procedure, I searched for any file, including binary ones as well, of my new USB key, the string
Fi, with this exact case, in regex mode and I got these results :Search "Fi" (32 189 hits in 624 files of 1 119 searched) [RegEx: Case] with native N++ v8.9.9.1 Search "Fi" (32 189 hits in 624 file(s)) [1 119 file(s) searched] with MultiReplace v6.2.0.38 32 189 matches in 624 of 1 118 files (Regex, match case): Fi with Search++ v0.8 (x64) And running the DOS command "rg -a --stats Fi", it displayed, at the end : 32189 matches 24492 matched lines 624 files contained matches 1118 files searched 12462212 bytes printed 498369521 bytes searched 0.173930 seconds spent searching 0.573693 seconds total
As you can see, the count of matches and the files concerned are identical for these
4tests However, the number of files analyzed varies :-
1,119for N++ and MultiReplace -
1,118for Search++ and rg.exe
I figured out why ! On my
D:key, I have only :-
One directory which is hidden :
System Volume Information -
One file which is hidden :
Thumbs.db
As the
Hidden foldersoption was unchecked,N++andMultiReplacedid not consider the folderSystem Volume Informationbut did take in account theThumbs.dbfile !Whereas,
the Search++plugin and thergsoftware did not consider, both, hidden files AND folders. Thus, it did not analyse theThumbs.db, as well !Consequently, @coises, I suppose that you have enough place to modify the label of the option from
Hidden filestoHidden files and folders. Alternatively, you could also decide to add a new optionHidden folders. Do as you like !
Now, I ran the same tests again, on
txtfiles ONLY and there are the results :•==============•==========•========•===========•===============•===============•==========================• | Software | Hits | In | Scanned | First Time | Second Time | Command | | / Plugin | | Files | Files | After Restart | Right after | | •==============•==========•========•===========•===============•===============•==========================• | Notepad++ | 10600 | 311 | 641 | 17 s 25 " | 5 s 32 " | | •--------------•----------•--------•-----------•---------------•---------------•--------------------------• | MultiReplace | 10600 | 311 | 641 | 11 s 80 " | 1 s 78 " | | •--------------•----------•--------•-----------•---------------•---------------•--------------------------• | Search++ | 10600 | 311 | 641 | 16 s 94 " | 0 s 66 " | | •--------------•----------•--------•-----------•---------------•---------------•--------------------------• | rg.exe | 10600 | 311 | 641 | 16 s 69 " | 0 s 55 " | rg -a -ttxt --stats Fi | •==============•==========•========•===========•===============•===============•==========================•Best Regards,
guy038
P.S. : Please note that the tests were all conducted BEFORE I wrote this post, which, obviously, modify the results !
-
-
Refer to https://github.com/BurntSushi/ripgrep.
An interesting and sophisticated piece of software. It is written in Rust and by default uses that language’s regular expression search engine, which is a “finite state machine” implementation rather than a “backtracking” implementation. The practical effect of that is that the default engine doesn’t support lookarounds or backreferences, though it does support some constructs Boost::regex does not. It also avoids the “complexity” error that can occur during matching with Boost::regex. (The expression itself can still be “too complex,” but if it is, that’s known before matching ever begins.)
One of the “someday…” wishes I have for Search++ is to add an alternate regex engine that uses a finite state machine (e.g., RE2), for use when the search expression doesn’t need backtracking-only features but the total space to be searched is huge.
Consequently, @coises, I suppose that you have enough place to modify the label of the option from
Hidden filestoHidden files and folders. Alternatively, you could also decide to add a new optionHidden folders.Yes, I see I should be more clear. Without thinking about it, I always assumed that if you were excluding “hidden” anything, that meant both hidden files and anything that could only be reached through a hidden folder. I hadn’t realized that Notepad++’s native search would still search hidden files if that box was not checked, so long as they weren’t in a hidden folder.
I’m curious whether you, or anyone, foresees practical cases in which you would want to omit one from a search but not the other.
-
Hi, @coises and All,
You said :
The practical effect of that is that the default engine [ of rg.exe ] doesn’t support lookarounds or backreferences …
Well, actually, if you choose the
--pcre2option, it does support them ! For example :The
rg -a -t txt --stats Fi(?=le)DOS command returns :C:\>d: D:\>rg -a -t txt --stats Fi(?=le) rg: regex parse error: (?:Fi(?=le)) ^^^ error: look-around, including look-ahead and look-behind, is not supported Consider enabling PCRE2 with the --pcre2 flag, which can handle backreferences and look-around. D:\>And, indeed, the command
rg -a -t txt --stats --pcre2 Fi(?=le), after a restart, is quite functional and give these results :2250 matches 1596 matched lines 104 files contained matches 642 files searched 271490 bytes printed 88413019 bytes searched 130.606157 seconds spent searching 17.113812 seconds totalNote that I do not understand why the total search took about
17 sand the search, itself, took about130 s? But this is an off-topic question !
Then, the next step, to my mind, was to try, for example, the regexes :
(?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=S=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X (?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=Š=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=ū=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X (?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=S=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X Our friend Sarunas Our friend Šarūnas Our friend ŠarūnasAnd verify if EACH of these three regexes did match the three lines beginning with
Our friend ..., right below !Alas, thrice alas ! The program returns the message :
D:\>rg --stats --pcre2 (?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=Š=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=ū=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X Coises.txt rg: PCRE2: error compiling pattern at offset 12: POSIX collating elements are not supported D:\>Even this simple command, below, fails :
D:\>rg --stats --pcre2 [[=q=]] Coises.txt rg: PCRE2: error compiling pattern at offset 9: POSIX collating elements are not supported D:\>You can verify this assumption, at the end of this page : https://www.regular-expressions.info/refcharclass.html

Now, you said :
I’m curious whether you, or anyone, foresees practical cases in which you would want to omit one from a search but not the other.
Well, I do not need that distinction for myself ! It’s just that your excellent
Search in Filesdialog can already filter :-
By folder
-
And /or by included extensions or excluded extensions or regex
-
And/or by size
-
And/or by date-type and date
Thus, it seemed to me that you could also add these two separate options
Hiden filesandHidden folders, in order that this dialog was even more flexible ! But, of course, do as you like ;-)Best Regards,
guy038
-
-
Hello, @coises and All,
You said, in a previous post :
I do think it would be possible, and that it would be a useful enhancement.
I haven’t studied the problem in detail yet. The relevant concepts exist and are well-defined: Unicode canonical equivalence and compatibility equivalence. Probably someone has already implemented practical searches using canonical and compatibility equivalence in open source code,
To my mind, we do not need the help of anyone to achieve such a feature. Of course, my statement seems a little pretentious, but consider this :
In your
Search++plugin’s code, the ONLY thing you have to do, in order to use this fantastic improvement, would be :- When the
Plainbutton is selected, to use this layout :
□ M̱atch case □ Whole word only □ Matches all U̱nicode forms- When the
Regexbutton is selected, to use this layout :
□ M̱atch case □ Ḏot matches line breaks □ Free spacing̱ □ Unicode word ḇoundaries ( greyed )- When the
ICUbutton is selected, to use this layoout
□ M̱atch case □ Ḏot matches line breaks □ Free spacing̱ □ Unicode word ḇoundariesThus, when the
Search++dialog is selected :ALT + B toggles 'Unicode word boundaries' ( ICU mode ) ALT + D toggles 'Dot matches line breaks ( Regex / ICU mode ) ALT + G toggles 'Free spacing' ( Regex / ICU mode ) ALT + M toggles 'Match case' ( Plain / Regex / ICU mode ) ALT + U toggles 'Match all Unicode forms' ( Plain mode ) ALT + W toggles 'Whole word only' ( Plain mode )-
Then, as long as, both, the
Plainbutton and theMatch all Unicode formsoption are selected : -
Switch INTERNALLY to the
Regex mode -
Replace, INTERNALLY, ANY character
•of the text ( ABOVE\x001Fand different from\R), within the search window, by the regex(?=[[=•=]])\X
That’s all !
One short example : internally, IF the search dialog contains :
-
The
Sarunstring, you would change it with the regex(?=[[=S=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X -
The
Šarūnstring, you would change it with the regex(?=[[=Š=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=ū=]])\X(?=[[=n=]])\X -
The
Šarūnstring, you would change it with the regex(?=[[=S=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X
And you can verify that each of these three regexes do match the three strings
Sarun,ŠarūnandŠarūn, simultaneously !!Best Regards,
guy038
P.S. :
-
In the first string
Sarun, NO character with an accent -
In the second string
Šarūn, two single chars with an accent (Šandū) -
In the third string
Šarūn, two characters with a base letter (Sandu) followed with an accent ( ̌ and ̄ )
- When the
-
In your
Search++plugin’s code, the ONLY thing you have to do, in order to use this fantastic improvement, would be :- When the
Plainbutton is selected, to use this layout :
□ M̱atch case □ Whole word only □ Matches all U̱nicode formsWell, one immediate problem is that [[=x=]] doesn’t respect case, regardless of whether (?i) or (?-i) is in effect.
Beyond that, I’m thinking that there ought to be the ability to choose to match using canonical equivalence or compatibility equivalence. In fact, for plain text searches especially, I suspect canonical equivalence is what most people would expect. It probably should be the default.
- When the
-
Hello, @coises and All,
Could you enlighten me of a weird behaviour within your two plugins
ColumnsPlusPlusandSearch++?
we’ll try to use the
(?s)^xyz.+|^abc.+regex against this text, pasted in a new tab :This is a test abc with some text to see xyz if everything works properly-
Place the caret at beginning of the
5thlineto see -
Use the
Replace All After in Whole Documentoption => The third last lines are deleted => OK -
Now, use the
Replace All Before in Whole Documentoption => MessageNo match found before current position! Why ? to my mind, the(?s)^xyz.+|^abc.+regex should have matched the3lines :
abc with some text to seeOf course, if we use, instead, the
Replace All in Whole Documentoption, it does delete these three lines !
A similar behaviour occurs with the
ColumnPlusPlusplugin. I use this layout :
-
Place the caret at beginning of the
5thlineto see -
Use the
Replace Afteroption => The third last lines are deleted, all the remaining text is colored with the custom style and the messageOne replacement madeis displayed => OK -
Now, use the
Replace Beforeoption => we get the messageNo match found, with all text still in custom style

Of course, if we use, instead, the
Replace Alloption it does delete the three lines from stringabcBest Regards,
guy038
P.S. :
See also the end of this post : https://community.notepad-plus-plus.org/post/106889
-
-
- Now, use the
Replace All Before in Whole Documentoption => MessageNo match found before current position! Why ? to my mind, the(?s)^xyz.+|^abc.+regex should have matched the3lines :
abc with some text to seeMatching before and after are defined as:
-
Before applies the command action only to matches that occur to the left and upward in the active document relative to the current position or selection. The action is not applied to matches which overlap the current position or selection.
-
After applies the command action only to matches that occur to the right and downward in the active document relative to the current position or selection. The action is not applied to matches which overlap the current position or selection.
It could be that this is not what people expect, which might indicate a design problem. I will have to consider that.
The commands do not match “within the part of the document that occurs before or after the caret or selection”; they match within the whole document, accepting only matches which occur entirely before or after the current position or selection. Since the current position in your example is within the matched text, that match is not considered to be “before” the current position.
- Now, use the
-
Hi, @coises,
Oh… I see ! So using the same text below and the same regex (
(?s)^xyz.+|^abc.+) of my previous post :This is a test abc with some text to see xyz if everything works properly-
First, I placed the caret at beginning of the
5thlineto see. As NO colored zone exists, the whole document was supposed to be the scope ! -
Using the
Replace Afteroption => The third last lines were deleted and the messageOne replacement madewas displayed -
Moreover, the entire lines, with their line-breaks, were colored with the custom style => OK
-
Then I placed the caret at end of the fifth line, between the word
seeand its line-break -
After running the
Replace Beforeoption => I got the messageNo matches found. This is the expected behavior as the caret is INSIDE the colored zone and scope ! -
Finally, I placed the caret at the beginning of the virtual line
6, so OUTSIDE the colored zone -
After running the
Replace Beforeoption, again => The three lines, beginning with the stringabc, were deleted and the messageOne replacement madewas displayed
BR
guy038
-
-
-
Moreover, the entire lines, with their line-breaks, were colored with the custom style => OK
-
Then I placed the caret at end of the fifth line, between the word
seeand its line-break -
After running the
Replace Beforeoption => I got the messageNo matches found. This is the expected behavior as the caret is INSIDE the colored zone and scope !
No, you are missing the point.
The custom style coloring is a consequence of how Columns++ Search in indicated region works. Columns++ is always doing the equivalent of what in Search++ would be a search in Marked Text. When there is no selection, nothing is marked and Auto set is checked, all text in the document is marked with the custom style. That isn’t the cause of the difference between what you’re seeing and what you expect.
Compare what happens if you do your original test with this expression instead:
(?-s)^xyz\R.+|^abc\R.+In Columns++ you’ll see the coloring, in Search++ you won’t, but the results will be the same: both After and Before will work.
To see why your original expression didn’t work for Before, start fresh again, use your original expression, do Replace After and then do Select All (no Before).
Notice that the selected area includes where your caret was. That is why it isn’t considered to be a match Before the current position.
-
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