Help please with regex

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
burgundy
Posts: 273
Joined: Fri Oct 16, 2009 9:50 am

Help please with regex

Post by burgundy »

I want to find all files from CIMG0001 to CIMG9999 on the D: drive

As far as I can tell, I need to use regex although I am not very good at it! I get this far:
CIMG[0-9][0-9][0-9][0-9]
(Q1) How do I also specify the D: drive in regex?

(Q2) How do I specify JPG files in regex? Sometimes my file names contain some additional text between "CIMGxxxx" and the file extension.
froggie
Posts: 302
Joined: Wed Jun 12, 2013 10:43 pm

Re: Help please with regex

Post by froggie »

Without "enable regex" selected in search try

d:\ ext:jpg;jpeg regex:^CIMG[0-9][0-9][0-9][0-9]



Everything ANDs the terms together. It is not necessary to have them all within the regx. The "^" says match at beginning of filename.
burgundy
Posts: 273
Joined: Fri Oct 16, 2009 9:50 am

Re: Help please with regex

Post by burgundy »

That works nicely. Much obliged!

Out of interest, is there a way to specify the drive letter or the JPG file extension within a regex?

I mean when Everything is set to Menu > Search > Enable Regex
froggie
Posts: 302
Joined: Wed Jun 12, 2013 10:43 pm

Re: Help please with regex

Post by froggie »

The jpg is easy, just add
.*\.(jpg|jpeg)
after the last [0-9].

When you add the D:\ to the regex, you have to match the entire path up to the CIMG, so you end up with
P:\\.*CIMG[0-9][0-9][0-9][0-9].*\.(jpg|jpeg)
, which is fine as long as there is no folder with a CIMGnnnn name.

I generally find that using the minimum amount of regex is the quickest way for me, although regex is very powerful when you need it.
RegexNinja
Posts: 18
Joined: Sat Apr 11, 2020 2:45 pm

Re: Help please with regex

Post by RegexNinja »

Hi, just wanted to note that some of the regexes could match names like abcCIM0001.jpg or CIM0001xyz.jpg
If its important to filter such names, you can use things like:
regex:"D:.*\\CIMG[0-9][0-9][0-9][0-9]\.(jpg|jpeg)$"
regex:"D:.*\\CIMG[0-9]{4}\.jpe{0,1}g$"
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Help please with regex

Post by NotNull »

froggie wrote: Tue Sep 29, 2020 9:27 pm When you add the D:\ to the regex, you have to match the entire path up to the CIMG, so you end up with
P:\\.*CIMG[0-9][0-9][0-9][0-9].*\.(jpg|jpeg)
, which is fine as long as there is no folder with a CIMGnnnn name.
To prevent finding foldernames with CIMGnnnn in their name:
^P:.*\\CIMG[0-9][0-9][0-9][0-9][^\\]*\.(jpg|jpeg)$


(but that is all getting a little overcomplicated; I agree with froggie: "I generally find that using the minimum amount of regex is the quickest way for me, although regex is very powerful when you need it.")
Post Reply