skij
asked on
PHP/REGEX: Where file names do not have underscore with glob
$f = glob('files/courses/{*_[0-9]*.zip}', GLOB_BRACE);
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
?
add a ? after the _
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.
x_123.zip
y_543.zip
z_789.zip
If there is a _ before the number then it should not match.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
{[a-zA-Z0-9]+.zip}
ASKER
Please look carefully at the examples I gave in my original post.
None of the ideas work with the examples provided.
None of the ideas work with the examples provided.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For interest FSI ran in approx 1/5 of the time of the glob solution.