I have yet to find a good example of how to use the php RegexIterator to recursively traverse a directory.
The end result would be I want to specify a directory an
The docs are indeed not much helpful. There's a problem using a regex for 'does not match' here, but we'll illustrate a working example first:
The problem is the doesn't match .Trash[0-9]{3}
part: The only way I know how to negative match the directory, is match the end of the string $
, and then then assert with a lookbehind (? 'if it is not preceded by '/foo'.
However, as .Trash[0-9]{1,3}
is not fixed length, we cannot use it as a lookbehind assertion. Unfortunately, there is no 'invert match' for a RegexIterator. But perhaps there are more regex-savvy people then I knowing how to match 'any string not ending with .Trash[0-9]+
edit: got it '%([^0-9]|^)(? as a regex would do the trick.