MRT: need Help with regex (Num +) (de/select files)

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
miskox
Member
Member
Posts: 170
Joined: 2003-06-11, 06:00 UTC

MRT: need Help with regex (Num +) (de/select files)

Post by *miskox »

Hello all!

I need some help. I have lots of files that end with a number (0-9).

If I want to select files with only odd or even numbers at the end of a filename (xxx0.png for example) I can use

(with some of google help I ended up with this)

Press NUM+ (select files) and enter this:

Code: Select all

<^.*[02468]\.png$
This equals to:
*0.png
*2.png
*4.png
*6.png
*8.png
So I have only *.png* files with even numbers at the end selected.

How can I change my initial regex to select *0.* ---- instead of .png I would like to have an asterisk? (of course instead of 0 (zero) there are 2,4,6,8)

This does not work:

Code: Select all

<^.*[02468]\.*$
Thanks.
Saso
#224551
User avatar
obeg
Junior Member
Junior Member
Posts: 43
Joined: 2006-09-28, 09:20 UTC
Location: Sweden

Re: Help with regex (Num +) (de/select files)

Post by *obeg »

If you want to match anything with a regexp it is .* , just like in the beginning of the expression (any charachter, 0 to many times)
^ indicates start of and $ end.

Code: Select all

<^.*[02468]\..*$
br /ola
User avatar
Stefan2
Power Member
Power Member
Posts: 4157
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Help with regex (Num +) (de/select files)

Post by *Stefan2 »

 
\. ==> means a literal dot itself, and not a dot . to match one peace of anything.
* ===> means "none-or-more" of the part just before, a literal dot in your example.
So your '\.*" try to match "none-or-more" of a literal dot.



So what you want is to match a literal dot (\.), followed by "one-or-more" of any sign (.+)
So try: \..+


<^.*[02468]\..+$




- - -
<^.*[02468]\..*$ will work too in case of filename, as there must be anything
following the last dot, as trailing dots are not allowed in Win32 file system.
But "one-or-more" (+) is more correct than "none-or-more" (*) 8) :mrgreen: :wink:
- - -


HTH? :D
miskox
Member
Member
Posts: 170
Joined: 2003-06-11, 06:00 UTC

Re: Help with regex (Num +) (de/select files)

Post by *miskox »

Thank you. Both solutions work.

Great!

Have a nice day.
Saso
#224551
Post Reply