sorting by string embedded in a property value (e.g. name)

Discussion related to "Everything" 1.5 Alpha.
Post Reply
jimspoon
Posts: 187
Joined: Tue Apr 26, 2011 11:39 pm

sorting by string embedded in a property value (e.g. name)

Post by jimspoon »

Say I want to sort found files by a string contained somewhere in the filename, for example, and underscore followed by four digits, no matter where in the filename it occurs.

This works: "regex:name:_\d\d\d\d sort:regmatch0"

I thought I had it working also with "sort:name:regex:_\d\d\d\d" but later I discovered it wasn't working. Is there some variation on this that would work? But of course using "sort:regmatch0" is certainly easy enough.
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: sorting by string embedded in a property value (e.g. name)

Post by NotNull »

Don't think there is.

In case you need to do something further down the line with these numbers, this should work too:

Code: Select all

regex:"name:_(\d\d\d\d)"    addcolumn:regmatch1   sort:regmatch1
This way the () capture group is the only thing shown in the regmatch1 column, consisting of just the four numbers, which makes it right aligned.
regmatch0 includes the underscore, which makes the match be considered text.


(the addcolumn:regmatch1 is not strictly needed, but helpful in giving feedback)
Post Reply