Regex problem

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
Boz
Posts: 6
Joined: Sun Oct 03, 2021 3:11 pm

Regex problem

Post by Boz »

I've recently started using Everything and am very impressed with it's speed and ease of use.
I have no experience with regex and am not even sure if regex is the right method to use.
The filenames always follows the same format

XXXX-YYYYYY-Iss?

XXXX is a four digit number which defines a component type
YYYYYY is a unique 6 digit number
Iss? is the revision issue, the ? can be any capital letter between A-Z or a number from 1 to whatever.

What I want to do is find the latest revision of a file.

Example of files that might exist

0020-001234-IssA
0020-001234-IssB
0020-001234-IssC
0020-001234-Iss1
0020-001234-Iss2

I want to find the last file 0020-001234-Iss2

I imagine this is a simple task, but one that is beyond me!

Regards

Boz
raccoon
Posts: 1017
Joined: Thu Oct 18, 2018 1:24 am

Re: Regex problem

Post by raccoon »

Would you be willing to adopt a new revision numbering scheme and rename all your files, dropping the A-Z and using 001-999 instead? And also a filename prefix for this family of files? eg:

BOZTOOLZ-0020-001234-rev005

Everything doesn't have a mechanism sort in that order, with letters first and then multi-digit numbers.

I can help you write a batch file to rename the files to this new format.
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex problem

Post by void »

Similar to this question..

To match XXXX-YYYYYY-Iss with regex, please try the following search:

regex:File\d-Rev-[A-Z]

regex:\d\d\d\d-\d\d\d\d\d\d-Iss


regex: = enable regular expressions.
\d = match a single digit
I want to find the last file 0020-001234-Iss2
This is trickier to do..
You will need Everything 1.5 alpha or later.

<regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)A(.*)$ !file-exists:\1B\2 !file-exists:\1C\2> | <regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)B(.*)$ !file-exists:\1C\2> | <regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)C(.*)$> | <regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)1(.*)$ !file-exists:\12\2 !file-exists:\13\2> | <regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)2(.*)$ !file-exists:\13\2> | <regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)3(.*)$>

Only Rev A-C and 1-3 is supported with the above.
Is there a Rev higher than C or 3?
Boz
Posts: 6
Joined: Sun Oct 03, 2021 3:11 pm

Re: Regex problem

Post by Boz »

Thanks for the quick reply.

I'm using 1.5 alpha.
There could be Iss higher than C, H is the highest I have ever seen,
realisticaly the highest numeric value would not exceed 10.
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex problem

Post by NotNull »

So the old-to-new order is: A B C D E F G H 0 1 2 3 4 5 6 7 8 9 ?

That is quite peculiar, as that is not the alphabetical order. Computerprograms (including Everything) will have problems with that ...
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex problem

Post by void »

It's not very practical, but....

Code: Select all

#define:<p[x]=#<:regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)#x:(.*)$#>:>#define:<e[x]=#<:file-exists:\1#x:\2#>:><#p:<A> !#e:<B> !#e:<C> !#e:<D> !#e:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<B> !#e:<C> !#e:<D> !#e:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<C> !#e:<D> !#e:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<D> !#e:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>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#p:<0> !#e:<1> !#e:<2> !#e:<3> !#e:<4> !#e:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<1> !#e:<2> !#e:<3> !#e:<4> !#e:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<2> !#e:<3> !#e:<4> !#e:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<3> !#e:<4> !#e:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<4> !#e:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<7> !#e:<8> !#e:<9>>|<#p:<8> !#e:<9>>|<#p:<9>>
#define:

supports A-Z and 0-9
Boz
Posts: 6
Joined: Sun Oct 03, 2021 3:11 pm

Re: Regex problem

Post by Boz »

Thanks for the reply, the solutions isn't quite want I would like to achieve, in as much that it lists every file that fit the regex expression.
What I would like if possible is to show only the one file, either the highest Issue (Iss) number or the highest letter Issue if there are no numeric Issue exist.

Example taken from set of files:

0020-001437-IssA
0020-001437-IssB
0020-001437-IssC
0020-001437-IssD
Above are pre-production issue files

Below are production files which contain changes to specifications
0020-001437-Iss1
0020-001437-Iss2
0020-001437-Iss3
0020-001437-Iss4
0020-001437-Iss5

I like to be able to show only the file at Iss5 by typing 001437 which is unique 6 digit number in the file system.

e.g.
If I typed for instance 004517 it would display one file with the highest alpha Issue if only pre-production files exist, or
the highest number issue if the file is used in production.

Big ask I think, but thanks trying,
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex problem

Post by void »

Does sorting by name descending help?

The highest rev should be the top result.
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex problem

Post by NotNull »

This is how far I got, but in the end that didn't work out as #eval does not seem to like regex.
And it needs to take care of just pre-production versions (that part should be easy)
Maybe someone else can fix it.

Code: Select all

<  regex:^(0020-001437-Iss)(.)(.*)$      !file-exists:\1<#eval:<1+\2>>\3  >
(relies on some trickery: #eval[1+A] = 1 and #eval[1+5]= 6. Note that #eval[A + 1] = 0 )


This assumes that there are no missing intermediate revisions: if there is lssA and lssD, there will also be lssB and lssC
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex problem

Post by void »

Please consider creating a filter, activating this filter and searching for 001437 :
  • In Everything, from the Search menu, click Add to filters...
  • Change the Name to: Highest xxxx-xxxxxx-Issx
  • Change the Search to:

    Code: Select all

    #define:<p[x]=#<:regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)#x:(.*)$#>:>#define:<e[x]=#<:file-exists:\1#x:\2#>:><#p:<A> !#e:<B> !#e:<C> !#e:<D> !#e:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<B> !#e:<C> !#e:<D> !#e:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<C> !#e:<D> !#e:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<D> !#e:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<E> !#e:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<F> !#e:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<G> !#e:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<H> !#e:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<I> !#e:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<J> !#e:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<K> !#e:<L> !#e:<M> !#e:<N> !#e:<O> !#e:<P> !#e:<Q> !#e:<R> !#e:<S> !#e:<T> !#e:<U> !#e:<V> !#e:<W> !#e:<X> !#e:<Y> !#e:<Z>>|<#p:<L> !#e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#e:<9>>|<#p:<2> !#e:<3> !#e:<4> !#e:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<3> !#e:<4> !#e:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<4> !#e:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<5> !#e:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<6> !#e:<7> !#e:<8> !#e:<9>>|<#p:<7> !#e:<8> !#e:<9>>|<#p:<8> !#e:<9>>|<#p:<9>>
    
  • Change the Macro to: highestiss
  • Click OK.
  • Filters can be activated from the Search menu, Filter bar (View -> Filters), right clicking the status bar, filter macro or filter keyboard shortcut.
  • Please activate this new filter.
  • Type in your search, eg: 001437
or, with the above filter and the Everything filter active, you could use the highestiss macro by searching for:
001437 highestiss:

!file-exists:\1<#eval:<1+\2>>\3 >
Unfortunately, this will not work as #eval: is expanded before the search is executed. (not when file-exists: is evaluated)
Boz
Posts: 6
Joined: Sun Oct 03, 2021 3:11 pm

Re: Regex problem

Post by Boz »

Thanks void and everyone who took the time to contributed, works great.

I like this program more every time I use it. :D
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Regex problem

Post by NotNull »

void wrote: Fri Oct 08, 2021 2:51 am Unfortunately, this will not work as #eval: is expanded before the search is executed. (not when file-exists: is evaluated)
Ah, yes, of course. Makes perfect sense (in hindsight :))
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex problem

Post by void »

It would be useful.

I have put on my TODO list: expand preprocessor text when evaluating fileexists:
Preprocessor text can be escaped with #<: and #>:

Thanks for the suggestion.
Boz
Posts: 6
Joined: Sun Oct 03, 2021 3:11 pm

Re: Regex problem

Post by Boz »

I tried the search you sent me, it worked fine on my home computer with dummy data, unfortunately
when I tried it at work I couldn't get any results. The files at work are stored on a NAS server, other searches
I use find files on the NAS server. I created a debug file, but don't how to upload it.
therube
Posts: 4977
Joined: Thu Sep 03, 2009 6:48 pm

Re: Regex problem

Post by therube »

void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex problem

Post by void »

Please zip the Everything debug log.txt and send to support@voidtools.com

If the zip file is larger than 10MB, please let me know.
Boz
Posts: 6
Joined: Sun Oct 03, 2021 3:11 pm

Re: Regex problem

Post by Boz »

Thanks for looking at the Debug log. It would appear there was some corruption when I change from Version 1.4 to 1.5.

Did a clean install of version 1.5 now all good, I been using the search you gave me at work, absolutely brilliant, I'm very impressed

with Everything, the program I mean.

Thanks again
void
Developer
Posts: 16748
Joined: Fri Oct 16, 2009 11:31 pm

Re: Regex problem

Post by void »

Everything 1.5.0.1296a adds an expand: search modifier.

expand: will simplify the file-exists: search for you:

regex:^(\d\d\d\d-\d\d\d\d\d\d-Iss)(.)(.*)$ !expand:file-exists:#<:\1#char:<#eval:<#unicode:<\2>+1>>\3#>:


Note that the preprocessor text in expand: is escaped with #<: and #>:
This will prevent the preprocessor text from being prematurely expanded.
expand: can use \1 - \9 to reference the previous regular expression capture groups.
Post Reply