tags:

views:

25

answers:

1

I would like to build something to filter filenames in a fashion similar to SVN's global-ignores format. I am guessing it might be best to parse the string (below) and generate a regular expression for it, but I am not sure if there is a better way to do this or if it has already been implemented somewhere.

*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store

Alternate suggestions would be appreciated!

+2  A: 

explode() and fnmatch() (glob() does not support negation).

Ignacio Vazquez-Abrams
This technically answers my question, but I think I may go with a `preg_match` solution anyway. I have a feeling that it will be more efficient than looping around a bunch of `fnmatch()` calls for each pattern.
Beau Simensen