Need regex for globbing function
Posted: Sun Apr 16, 2006 10:03 pm
So i've written a recursive globbing funciton...
The above is my regex to match EVERY file or folder on the system, recursively searching directories, etc...
Heres the problem...
If I wanted to narrow that search down, to say PHP and GIF files, how would I do that?
Here is what I have right now:
If your a regex hack you see the problem...
If finds files like:
- test.php.dat
Even though .dat is NOT what i'm looking for
Also, in order for the recursion to work, it needs to match folders as well, which obviously don't likely have PHP extensions...
So I need a regex which will match any directory name or filename but also limit result to only certina file types...aka extensions!!!
Any ideas???
Cheers
Code: Select all
'/.+/'Heres the problem...
If I wanted to narrow that search down, to say PHP and GIF files, how would I do that?
Here is what I have right now:
Code: Select all
'/.+\.(php|gif)?/'If finds files like:
- test.php.dat
Even though .dat is NOT what i'm looking for
Also, in order for the recursion to work, it needs to match folders as well, which obviously don't likely have PHP extensions...
So I need a regex which will match any directory name or filename but also limit result to only certina file types...aka extensions!!!
Any ideas???
Cheers