class GLOB
****
Unix "glob"-style string patterns are what the various shells in Unix use to specify sets of file names. They are used in the Sather interpreter to specify class names, etc. This class takes a pattern string and a test string and determines whether the test string matches the pattern.
_
Here are the components of a glob pattern:
_
1) char Any pattern character except for the special characters "[{?*\" must be matched exactly in the text string.
_
2) '\' char The backslash character is used as an escape to enable matching of the special characters. The backslash may be followed by any character and the pattern matches that character.
_
3) '[' ... ']' If the left bracket character '[' appears unescaped, then it must be followed by a sequence of characters and a right bracket. This pattern matches any single character in the list. If a right bracket appears immediately after the left bracket, it is treated as an ordinary character rather than as the closing bracket. All characters between the two brackets except '-' are taken to be themselves (i.e. they aren't special or escaped). Sequences of the form "char1 '-' char2" are treated as a shorthand for a list of all the characters alphabetically between "char1" and "char2". '-' may be included in the set by making it the first or last character.
_
3) '{' str, str, ... '}' If the left brace character '{' appears unescaped, then it must be followed by a comma-separated list of strings. Nothing is escaped
_
4) '?' A question mark matches an arbitrary single character.
_
5) '*' An asterisk matches zero or more arbitrary characters.


Flattened version is here



Public


Features
is_legal_pattern(s:STR):STR
**** Void if `s' is a legal pattern string, an error message if not.
pattern_matches(pat,s:STR):BOOL
**** True if the glob pattern `pat' matches the string `s'.
pattern_matches(pat,s:STR,pst,sst:INT):BOOL
**** True if the pattern `pat' starting at character `pst' matches the string `s' starting at character `sst'.

The Sather Home Page