[Solved] Is This Pattern Matching Behavior Possible?

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
postfreq
Posts: 10
Joined: Mon Jun 26, 2023 7:11 am

[Solved] Is This Pattern Matching Behavior Possible?

Post by postfreq »

Hi everybody.

I've long wondered, is it possible to do the following?

Say we have items "apple cider" and "dandelion wine". For queries "ac", "ra" (not in order), or "pr" (note the lack of spaces between letters) I'd like to get "apple cider". And also, for "dw", "wa", and — importantly — "dd" I'd like to get "dandelion wine". I think this could be summarized as treating each letter as if it was spaced, but also letter count being meaningful. I hope this makes sense, I can provide other examples to show what I mean, I'm sure these weren't exhaustive.

(Please note that my main goal is to get the amount of typing down, so while I'm interested in whether this can be done at all, for this to be useful to me I would need to be able to automate away the regexes, or however this could be achieved, and only type in the letters.)
Last edited by postfreq on Sun Jan 14, 2024 6:59 pm, edited 1 time in total.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Is This Pattern Matching Behavior Possible?

Post by NotNull »

See Search modifier for substring matching

However, this will not search for the typed letters in a different order.



FWIW, I use the following to search for starting letters of words.
(np will not find notepad, but will find "this is Not a Problem")

Code: Select all

Name = Whatever you like
Search = regex:(^|\W)#[regexreplace:$param:,".","$0.*?\\W"#]:*
Macro = whatever suits you.
(requires Everything 1.5 )


(I will spare you the details of the search query as there is some trickery going on to make this work)
postfreq
Posts: 10
Joined: Mon Jun 26, 2023 7:11 am

Re: Is This Pattern Matching Behavior Possible?

Post by postfreq »

Oh these are very close! In fact, they are so close that I realised this does not in fact reduce the amount of typing for me, my intuition was way off. Sorry for troubling y'all. But I'm so glad to learn of these preprocessing magics, they seem to be powerful indeed.

By trickery do you mean the bits of regex that are responsible for selecting beginnings of words? I can't quite read it, but I'm bookmarking this to study it again when I need advanced regex processing.

Thank you!
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: [Solved] Is This Pattern Matching Behavior Possible?

Post by NotNull »

postfreq wrote: Sun Jan 14, 2024 6:58 pm By trickery do you mean the bits of regex that are responsible for selecting beginnings of words?
That too, but the devil was in the details: the trickery is in the start and end of the search.
\W means a non-word character. It can't be at the start or ending of the search query, so I had to add some extra "stuff".

postfreq wrote: Sun Jan 14, 2024 6:58 pm In fact, they are so close that I realised this does not in fact reduce the amount of typing for me
You can create a filter with these and instead of typing a macro -- for example: short:dsotm to find "The Dark Side Of The Moon" -- you can also assign a keyboard shortcut to that filter, like Alt-S.
Then typing ALT-S will enable this filter. Now you only need to type "dsotm".
Typing ALT-S again will revert to your default Everything filter.
Maybe that helps typing less ...



BTW: I just realized I also have written a verion where the "words" can be in any order: "dtmos" will also find ""The Dark Side Of The Moon".
Let me know if interested.

study it again when I need advanced regex processing
If it helps:
dsotm expands to regex:(^|\W)d.*?\Ws.*?\Wo.*?\Wt.*?\Wm.*?\W*
postfreq
Posts: 10
Joined: Mon Jun 26, 2023 7:11 am

Re: [Solved] Is This Pattern Matching Behavior Possible?

Post by postfreq »

You can create a filter with these and instead of typing a macro ... Maybe that helps typing less
Oh yeah, I did do that. Sorry if I wasn't clear, I meant the whole approach, this way of pattern matching, didn't actually help me type less. I misjudged how common most letters are among the files I'm filtering, so I have to enter way more characters this way. But also, for setting these as filters: I really like sectioning off my queries with "folder-name\", there's no way to exclude that or some other part of the query from the preprocessor, is there? In this case macros allow more control.

But anyway, these might well help in other cases, I find myself using Everything for more and more tasks lately. So I'm really glad to have these options, and please do share the expander for "dtmos", I'm very interested.

With that previous one, I maybe get some of it?

Code: Select all

regex:(^|\W)#[regexreplace:$param:,".","$0.*?\\W"#]:*
"ecl" would expand to something like this, right?
regex:(^|\W)e.*?\Wc.*?l.*?
I still don't get it get it, I just tried tinkering to at least start to get a feel for it. There are two specific questions that I have that maybe you could answer:

1. Why does \W need to be escaped there? (Which is what I assume the second slash is for.)
2. Does $0 loop through each letter somehow? When would we use $1, $2, etc?
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: [Solved] Is This Pattern Matching Behavior Possible?

Post by NotNull »

Running out of time, so the short version (maybe others step in to answer your other questions)

Code: Select all

Search = #[regexreplace:$param:,".","regex:(^|\\W)$0 "#]:
Post Reply