Package sunlabs.brazil.util
Class Glob
- java.lang.Object
-
- sunlabs.brazil.util.Glob
-
public class Glob extends java.lang.ObjectGlob-style string matching and substring extraction. Glob was implemented by translating the glob package for tcl8.0.- "*" matches 0 or more characters
- "?" matches a single character
- "[...]" matches a set and/or range of characters
- "\" following character is not special
- Version:
- 2.16
- Author:
- Colin Stevens (colin.stevens@sun.com)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanmatch(java.lang.String pattern, java.lang.String string)Match a string against a pattern.static booleanmatch(java.lang.String pattern, java.lang.String string, java.lang.String[] substr)Match a string against a pattern, and return sub-matches.
-
-
-
Method Detail
-
match
public static boolean match(java.lang.String pattern, java.lang.String string)Match a string against a pattern.- Parameters:
pattern- Glob pattern. Nothing matches if pattern==null.string- String to match against pattern.- Returns:
trueif the string matched the pattern,falseotherwise.
-
match
public static boolean match(java.lang.String pattern, java.lang.String string, java.lang.String[] substr)Match a string against a pattern, and return sub-matches.The caller can provide an array of strings that will be filled in with the substrings of
stringthat matched the glob meta-characters inpattern. The array of strings may be partially modified even if the string did not match the glob pattern. The array may contain more elements than glob meta-characters, in which case those extra elements will not be modified; the array may also contain fewer elements or even benull, to ignore some or all of the glob meta-characters. In other words, the user can pass pretty much anything and this method defines errors out of existence.- Parameters:
pattern- Glob pattern.string- String to match against pattern.substr- Array of strings provided by the caller, to be filled in with the substrings that matched the glob meta-characters. May benull.- Returns:
trueif the string matched the pattern,falseotherwise.
-
-