首页 > 解决方案 > 向正则表达式过滤器制造商寻求一个好的java“完整路径glob”

问题描述

我需要使用类似于或等效于 .gitignore 文件或 gradle 用于其 FileTree include() 和 exclude() 方法的通用完整路径“glob”过滤器格式来实现目录树遍历器。

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.

过滤器可以采用不带分隔符的字符串数组来表示路径。

是否为此制定了标准?一个好的实现?

如果是这样,我在哪里可以找到它:)

标签: javaglob

解决方案


推荐阅读