Seeking a good java "full path glob" to regex filter maker

Viewed 39

I need to implement a directory tree walker using a common full path "glob" filter format similar or equivalent to what a .gitignore file has in it or that gradle uses for its FileTree include() and exclude() methods.

ie:  "/**/aDirectory/*.foo" "/a/directory/**/*.foo" "/start/a????.d/**/*"  etc
That is:

filter = makeFilter("/**/*.foo/**/*.txt")

filter.match("/a/b/c/blah.foo/e/f.txt") == true;
filter.match("/a/b/c/blah.foo/e/f.jpg") == false;
filter.match("/a/b/c/blah/e/f.txt") == false;
filter.match("/blah.foo/e/f.txt") == true;
filter.match("/blah.foo/f.txt") == true;
  
also allowing "?" to represent a single character that must be present.

The filter can take a array of strings without the separators to represent a path.

Has there evolved a standard for this? A good implementation?

If so where might I find it :)

0 Answers
Related