Feature request: wildcards in text search.

Have a suggestion for "Everything"? Please post it here.
Post Reply
Janus
Posts: 75
Joined: Mon Nov 07, 2016 7:33 pm

Feature request: wildcards in text search.

Post by Janus » Wed Sep 30, 2020 5:53 pm

I am not sure how hard this would be to implement.
However, on those occasions when it is needed, it would help a lot.

content:"Sam*" Match Sam*, works normally.

For wildcard though, use single quotes.

content:'Sam*' Match any word starting with Sam
content:'*Sam' Match any word ending with Sam
content:'Sam*n' Match any word starting with Sam, ending with an N.
content:'Jan???y' Math any word starting with Jan then three letters and ending with an N.


Janus

NotNull
Posts: 2335
Joined: Wed May 24, 2017 9:22 pm

Re: Feature request: wildcards in text search.

Post by NotNull » Wed Sep 30, 2020 8:56 pm

That is already possible :)

When you combine the content: function with a modifier you can do things like:

Code: Select all

"C:\start folder"   ext:txt   wildcards:content:some*text
or

Code: Select all

"C:\start folder"   ext:txt   regex:content:some.*text
That would find "some short text" and "some very long text" in your files.
But it would also find lines with this text: "Everything is awesome. End of text."
For more info on functions and modifiers, see this page.

Searching for words is a little harder. Regex has a word boundary (\b) option in it's syntax: \btext\b
Using that and applied to your examples:

Match any word starting with Sam:
regex:content:\bSam


Match any word ending with Sam:
regex:content:Sam\b


Match any word starting with Sam, ending with an N:
regex:content:\bSam[^\b]*n\b


EDIT:
@RegexNinja pointed out to me that regex:content:\bSam.*n\b could also match multiple words, like "Sam has a kitten".
I fixed my mistake. Thanks, RegexNinja!

Math any word starting with Jan then three letters and ending with an Y:
regex:content:\bJan.{3}y\b




Note that Everything does a case INsensitive search in these cases. It will find Sam as well as sam.
If you want a case sensitive search, use (?-i). It is also part of the regex 'vocabulary'":
regex:content:(?-i)\bSam.*\b


You can not combine diacritics: with regex: so this doesn't work as you might expect: diacritics:regex:content:\bSam.*n\b



Note 2 You can also enclose the regular expression in "", like regex:content:"\bSam.*n\b". Makes it a little easier to distinguish (my opinion), but it is not ncessary.


Note 3 wildcards:content:some*text depends on the setting of Match whole filename when using wildcards (Options > Search )
If this option is enabled, some*text will try to find lines that start with "some" and end with "text".
To work around thatyou can:
- disable Match whole filename when using wildcards
- replace some*text with *some*text*
- add the noexact: modifier. ( "C:\start folder" ext:txt noexact:wildcards:content:some*text )

Post Reply