Constructors Constructor Description
All Methods Static Methods Concrete Methods Modifier and Type Method Description
match(String pat, String str)Match a pattern against a string and isolates wildcard replacement into a
matchMatch a pattern against a string and isolates wildcard replacement into a
Here is how the matching algorithm works:
- The '*' character, meaning that zero or more characters (excluding the path separator '/') are to be matched.
- The '**' sequence, meaning that zero or more characters (including the path separator '/') are to be matched.
- The '\*' sequence is honored as a literal '*' character, not a wildcard
When more than two '*' characters, not separated by another character, are found their value is considered as '**' and immediate succeeding '*' are skipped.
The '**' wildcard is greedy and thus the following sample cannot match:
- STAR,STAR,PATHSEP,STAR,PATHSEP,STAR,STAR (why can't I express it literally?)
A more advance algorithm could certainly check whether there is an other literal later in the pattern to ev. match in string but I'll leave this exercise to someone else ATM if one needs such.
pat- The pattern string.
str- The string to math against the pattern
Mapcontaining the representation of the extracted pattern. The extracted patterns are keys in the
Mapfrom left to right beginning with "1" for the left most, "2" for the next, a.s.o. The key "0" is the string itself. If the return value is null, string does not match to the pattern .