Link to home
Start Free TrialLog in
Avatar of skij
skijFlag for Canada

asked on

PHP/REGEX: Where file names do not have underscore with glob

$f = glob('files/courses/{*_[0-9]*.zip}', GLOB_BRACE);

Open in new window

This matches:
x_123.zip
y_543.zip
z_789.zip

But it does not match:
x123.zip
y543.zip
z789.zip

How can I get it to match:
x123.zip
y543.zip
z789.zip

but not:
x_123.zip
y_543.zip
z_789.zip
?
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

add a ? after the _
Avatar of skij

ASKER

I don't want these to match!
x_123.zip
y_543.zip
z_789.zip

If there is a _ before the number then it should not match.
SOLUTION
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
{[a-zA-Z0-9]+.zip}
Avatar of skij

ASKER

Please look carefully at the examples I gave in my original post.

None of the ideas work with the examples provided.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For interest FSI ran in approx 1/5 of the time of the glob solution.