can the Regex Syntax be used simultaneously?

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
void_hero
Posts: 12
Joined: Thu Aug 18, 2016 6:54 am

can the Regex Syntax be used simultaneously?

Post by void_hero » Sun Nov 08, 2020 11:51 am

=============version =============
Operation system: win10 1903
Everything: Version 1.4.1.992 (x64)

Hi Team,
i know the Regex Syntax, e.g:
^ Matches the start of the filename
$ Matches the end of the filename

while can they be used simultaneously, i mean, i want to search out the files with their name match the 2 criteria at the same time. e.g., ther're 3 files named: abc1.txt abc2.txt abc3.txt
i want to search them out simultaneously, i try to use
^abc .txt$
or
^abc $txt

both can't fulfill the request. so the question is: can the different Regex Syntax be used at the same time?

thank you.

ovg
Posts: 228
Joined: Thu Oct 27, 2016 7:19 pm

Re: can the Regex Syntax be used simultaneously?

Post by ovg » Sun Nov 08, 2020 2:03 pm

Code: Select all

regex:^abc\d\.txt$
or

Code: Select all

regex:^abc.\.txt$
for any one symbol after abc

void_hero
Posts: 12
Joined: Thu Aug 18, 2016 6:54 am

Re: can the Regex Syntax be used simultaneously?

Post by void_hero » Sun Nov 08, 2020 3:11 pm

Hi ovg,
i just tried your method, it works, thanks.
but...

Code: Select all

regex:^a.\.txt$
regex:^a\d\.txt$

regex:^ab.\.txt$
regex:^ab\d\.txt$
won't work. i.e.: not sure why "abc" is mandatory, does it mean 3 characters are minimal to input here for it working as expected?

thanks.

ovg
Posts: 228
Joined: Thu Oct 27, 2016 7:19 pm

Re: can the Regex Syntax be used simultaneously?

Post by ovg » Sun Nov 08, 2020 3:43 pm

Sorry, but it seems that you don't know about regex. (BTW I don't want to insult or offend you)
www.regex101.com
www.regular-expressions.info

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

Re: can the Regex Syntax be used simultaneously?

Post by NotNull » Sun Nov 08, 2020 4:26 pm

The most common used regex options can also be found in the Everything menu: Help > Regex Syntax (also available online )


Quick explanation:

The most important one for you is the "."
In the regex language that means: one single character.
If you want to search for a "." , like in ".txt", you have to tell the regex 'engine' that you want a literal "." and not the wildcard "."
"\." (without the "") will do that for you.

So, If you want to search for "abc" - random character - ".txt" using regex, you get:

Code: Select all

^abc.\.txt$
And If you want to search for "abc" - multiple random characters - ".txt" using regex, you get:

Code: Select all

^abc.*\.txt$

\d is regex-speak for: 1 digit

void_hero
Posts: 12
Joined: Thu Aug 18, 2016 6:54 am

Re: can the Regex Syntax be used simultaneously?

Post by void_hero » Mon Nov 09, 2020 6:29 am

hi NotNull,
thank you for your in detailed explanation, it help me to understand the logic here.
but, as i replied previously, i still don't know why it need "abc"(3 characters), can it work for 1 character, or 2 characters(sometimes, just remember 1-2 characters ^^)?

thank you.
NotNull wrote:
Sun Nov 08, 2020 4:26 pm
The most common used regex options can also be found in the Everything menu: Help > Regex Syntax (also available online )


Quick explanation:

The most important one for you is the "."
In the regex language that means: one single character.
If you want to search for a "." , like in ".txt", you have to tell the regex 'engine' that you want a literal "." and not the wildcard "."
"\." (without the "") will do that for you.

So, If you want to search for "abc" - random character - ".txt" using regex, you get:

Code: Select all

^abc.\.txt$
And If you want to search for "abc" - multiple random characters - ".txt" using regex, you get:

Code: Select all

^abc.*\.txt$

\d is regex-speak for: 1 digit

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

Re: can the Regex Syntax be used simultaneously?

Post by NotNull » Mon Nov 09, 2020 11:57 am

regex:^a.\.txt$
Will search for files that start with an "a", followed by one (1) random character, followed by ".txt" and no more characters after that.
(total filename length = 6)

regex:^a\d\.txt$
Will search for files that start with an "a", followed by one (1) digit, followed by ".txt" and no more characters after that.
(total filename length = 6)

regex:^ab.\.txt$
Will search for files that start with "ab", followed by one (1) random character, followed by ".txt" and no more characters after that.
(total filename length = 7)

regex:^ab\d\.txt$
Will search for files that start with "ab", followed by one (1) digit, followed by ".txt" and no more characters after that.
(total filename length = 7)



Take a good look at the description of "*".
I guess you want something like regex:^ab.*\d\.txt$

Another alternative would be:

Code: Select all

regex:^abc   regex:\.txt$
FWIW: You don't *need* regex to accomplish this. You could also search in Everything for - forexample - :
startwith:abc endwith:.txt
See Menu:Help > Search Syntax

void_hero
Posts: 12
Joined: Thu Aug 18, 2016 6:54 am

Re: can the Regex Syntax be used simultaneously?

Post by void_hero » Mon Nov 09, 2020 3:53 pm

Hi Mr./Mrs NotNull,
what a good teacher you're here!
i finally see what i expected here based on your teaching:

Code: Select all

regex:^a.*.txt$
this is what i could imagine at the end of the day,

and yup, i noticed the "Menu:Help > Search Syntax", but the purpose here is using 2 or more criteria:
"a & txt" here, anyway, startwith or endwith, i also tried it based on what you guide, and it also works.

also with Mr./Mrs ovg, you also guide a lot which is amazing to learn(though too much seems like from the start) ^^.

what a lively environment here, thank you a lot, have a nice day ahead!

Post Reply