Match any character any number of times

General discussion related to "Everything".
Post Reply
ChrisGreaves
Posts: 684
Joined: Wed Jan 05, 2022 9:29 pm

Match any character any number of times

Post by ChrisGreaves »

Win10/Everything 1.5.0.1315a(64bit).
The topic search specific files with some pattern under some folder? alerted me to the construct of a doubled-asterisk in a search string:-

Code: Select all

* = match any character (except \) any number of times
** = match any character any number of times
This has puzzled me. I have made a few trial efforts, but find that I do not understand the construct at all.

(1) Might someone please point me to some documentation that describes the "**" in more detail, and perhaps explains exactly how "**" differs from "*"?
(2) One of my trials was coded as "j**.txt" - no space in there - (attached image), which seems to be interpreted as
(2a) the pattern "*.txt" and
(2b) exactly ONE occurrence of the letter "j" in either the file name or the folder name. I expected to see every "j" in the full name highlighted.

I was running this trial on my T: drive data partition with 340,000 files, so I should be able to fabricate a benchmark folder from which to extract results.

Thanks, Chris
Attachments
Untitled.png
Untitled.png (69.96 KiB) Viewed 3512 times
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Match any character any number of times

Post by NotNull »

ChrisGreaves wrote: Sun Oct 09, 2022 10:52 am (1) Might someone please point me to some documentation that describes the "**" in more detail, and perhaps explains exactly how "**" differs from "*"?
* matches any text within backslash boundaries
** matches any text anywhere (beyond the backslash boundaries)

(2) One of my trials was coded as "j**.txt" - no space in there - (attached image), which seems to be interpreted as
(2a) the pattern "*.txt" and
(2b) exactly ONE occurrence of the letter "j" in either the file name or the folder name. I expected to see every "j" in the full name highlighted.
There is another setting involved here: Match whole filename when using wildcards (in the menu, under Tools => Options => Search).
This 'causes' j* to match names that *start* with a "j". To match a "j" anywhere in the name, use either *j* instead or uncheck aforementioned setting.

So all in all, I think you already grasped the concept :)
ChrisGreaves
Posts: 684
Joined: Wed Jan 05, 2022 9:29 pm

Re: Match any character any number of times

Post by ChrisGreaves »

NotNull wrote: Sun Oct 09, 2022 2:05 pm...
There is another setting involved here: Match whole filename when using wildcards (in the menu, under Tools => Options => Search).
This 'causes' j* to match names that *start* with a "j". To match a "j" anywhere in the name, use either *j* instead or uncheck aforementioned setting.
Thank you NotNull.
I found (Tools, Options) the box was checked ON, so I turned it OFF and reran my posted search string.
Untitled.png
Untitled.png (9.17 KiB) Viewed 3461 times
I now see that both "J"s in the fullname are bolded.
But there is no letter-J in the folder name.
I shall set up a better test case to see just what this double-asterisk means
So all in all, I think you already grasped the concept :)
Sadly, no, although I might be getting there. After all, knowing that we have both single- and double-asterisk is a starting point.
I suspect that I am trying to build a statement along the lines of "You should use double-asterisk when you want to ...'
Onwards and ever upwards!
Thanks again, Chris
Last edited by ChrisGreaves on Wed Mar 22, 2023 7:35 pm, edited 1 time in total.
anmac1789
Posts: 669
Joined: Mon Aug 24, 2020 1:16 pm

Re: Match any character any number of times

Post by anmac1789 »

The double asterisk means that the search item can be within the filename and/or path but if you use *j* then the single letter j will be found anywhere in the filename only
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Match any character any number of times

Post by NotNull »

Example with C:\Windows\notepad.exe

Usually, Everything checks only the part after the last backslash for matches.
This is the part you see in the Name column in Everything: notepad.exe.

So n* will find notepad.exe, whereas w* will not.



Everything can also search through the full filename (including path) for matches. In this case: C:\Windows\notepad.exe
This mode can be activated in a couple of ways:
- Enabling Match Path
- Specifying a \ in the search query
- Using ** wildcards

Now Everything will search in the entire C:\Windows\notepad.exe

The following searches will find notepad.exe:
c:**exe
c:\*\*.exe
**\*.exe
**exe
**win
\win**
\win*

The following will not:
c:\*.exe
\win\**


Long story short: Use ** when you wnat to search in the full filename (including path)
ChrisGreaves
Posts: 684
Joined: Wed Jan 05, 2022 9:29 pm

Re: Match any character any number of times

Post by ChrisGreaves »

NotNull wrote: Wed Oct 12, 2022 8:33 pmExample with C:\Windows\notepad.exe
C:\Windows\notepad.exe
Hi NotNull; well this was a nice set of exercises to enjoy with a cuppa.

In my tests below when I say “...if I append Notepad” I assume that your statement “will find Notepad” means “it may well be a needle in a haystack”. I am appending “Notepad.exe” as a test to check that such a file(s) is found.
The following searches will find notepad.exe:
c:**exe
Because ** will match any character in the path or name portion; in this case between the colon of the drive and the rightmost three characters of the Fullname
But to easily spot Notepad in the results I would prudently tag “<space>notepad” to the right-hand end of the search string

c:\*\*.exe
Because the first * will find any characters between the two backslashes (including presumably other backslashes) , while the second asterisk will find any characters between the rightmost (why???) backslash and the extent delimiter and extent characters.
But to easily spot Notepad in the results I would prudently tag “<space>notepad” to the right-hand end of the search string

**\*.exe
Because the ** will find any characters to the left of the rightmost (or any ???) backslash, and the * will match any characters between the rightmost (why??) backslash and the extent delimiter and extent characters
But to easily spot Notepad in the results I would prudently tag “<space>notepad” to the right-hand end of the search string

**exe
Because the ** will match any characters anywhere in the Fullname excepting the rightmost three characters which must match “exe”
But to easily spot Notepad in the results I would prudently tag “<space>notepad” to the right-hand end of the search string

**win (Wildcards_02.png)
?? The double asterisk says “Folders only” and the “win” says “and only folders whose name ends in “win”. That is, has “win” as the right-hand three characters.
“**win**\notepad.exe” seems to do the trick. I suspect that you were having a long day!

\win**
?? The “\win” says “folders that start with “win”; the double asterisk says “any characters that match in the remaining right-hand part of the filename)
\win** notepad.exe

\win* (Wildcards_03.png)
?? The backslash and “win” says “any folder or file whose name begins with “win”; the single asterisk says “any characters in the name:
Since by definition if the found object is a file, then notepad.exe will never be found, because “notepad.exe” does NOT begin with “win”
The following will not:
c:\*.exe (Wildcards_04.png)
The “C:\” says “In the root folder of the boot drive” and the “*.exe” says any name with an extent delimiter and the extent characters “exe”. Since I have no “.exe” files in the root folder, the search results will never show an .exe, let alone a specific Notepad.exe. Actually, I copied Everything64.exe in there and found it, just to show that I would find Notepad, were there a copy on my root folder.

\win\** (Wildcards_05.png)
The “\win\ says that there must be a three-letter folder “win” somewhere in the path, and the double-asterisk says ‘anything else goes fore and aft ??? What? I expected the “\win\ to match only folders in the root of any included drive. Does the “**” serve as a roving matcher, anywhere in the Fullname that is NOT specified? I thought that here ** would match only to the right of Fullnames with \win\.

This is complex stuff, and I am sure that I have not got it completely right, but thanks to your examples I think I can interpret double-asterisks now
Cheers, and many thanks,
Chris
Attachments
Wildcards_02.png
Wildcards_02.png (39.87 KiB) Viewed 2070 times
Wildcards_03.png
Wildcards_03.png (62.78 KiB) Viewed 2070 times
Wildcards_04.png
Wildcards_04.png (18.46 KiB) Viewed 2070 times
Wildcards_05.png
Wildcards_05.png (175.02 KiB) Viewed 2070 times
ChrisGreaves
Posts: 684
Joined: Wed Jan 05, 2022 9:29 pm

Re: Match any character any number of times

Post by ChrisGreaves »

anmac1789 wrote: Tue Oct 11, 2022 12:10 am The double asterisk means that the search item can be within the filename and/or path but if you use *j* then the single letter j will be found anywhere in the filename only
Thanks anmac1789. I used this as the basis for all my tests/exercise/examples!
Cheers, Chris
Post Reply