Matching strings to wildcards pattern is useful and often needed. Using regular expression may help, but is not a top performance solution.
Wildcard class matches strings to wildcard patterns using
? characters, and that does very fast and good!
Here are some examples:
Wildcard.match("CfgOptions.class", "*C*g*cl*"); // trueWildcard.match("CfgOptions.class", "*g*c**s"); // true!Wildcard.match("CfgOptions.class", "??gOpti*c?ass"); // trueWildcard.match("CfgOpti*class", "*gOpti\\*class"); // trueWildcard.match("CfgOptions.class", "C*ti*c?a?*"); // true
Wildcard class supports path matching wildcards. It matches path against pattern using
** wildcards. Both path and the pattern are tokenized on path separators (
** represents deep tree wildcard, as in Ant.
Wildcard.matchPath("/foo/soo/doo/boo", "/**/bo*"); // trueWildcard.matchPath("/foo/one/two/three/boo", "**/t?o/**"); // true
Wildcard matching is used in many places in Jodd. As the general rule-of-the-thumb, everywhere where file paths are involved in scanning and matching, the
matchPath() method is used, otherwise, the classic