Page 1 of 1

Wildcards question?

Posted: Thu Apr 20, 2006 1:26 pm
by alex.barylski
When dealing with wildcards on a command line using ls or whatever, is it possible to using regex, extract the extension(s) of files that are currently being sought???

Is it safe to just use a simple substr() and extract everything after the first '.'???

Can regex be used to extract that string?

Cheers :)

Posted: Thu Apr 20, 2006 1:53 pm
by Ollie Saunders
Is it safe to just use a simple substr() and extract everything after the first '.'???
you are right to question this because it isn't. try pathinfo.

Posted: Thu Apr 20, 2006 1:54 pm
by feyd
regex can perform it, yes.

Posted: Thu Apr 20, 2006 2:37 pm
by alex.barylski
feyd wrote:regex can perform it, yes.
100% all the time?

Is something like this not possible using wildcards:

Code: Select all

a???_test{.bmp; .pdf}
as opposed to:

Code: Select all

a???_test.bmp
I've read up on using unix wildcards and it seems pretty flexible...which made me think impossible to parse using regex - I should say to always extract the extension(s) being searched...

I don't suppose you would care to show me the regex required for such a task - if indeed you can perform such an extraction... 8)

Cheers :)

Posted: Thu Apr 20, 2006 2:42 pm
by feyd
A properly written regex should be able to pull the information. Some additional processing may be required, but that is beyond regex's control.