Pattern Matching

The Filter property and the PatternMatch method can operate in two modes depending upon the setting of UseGrepMatch. Both modes pay attention to KeyCaseSensitive but only grep-style matching is aware of the MatchWholeWord property.

Note that grep-style matching is significantly slower.

Simple pattern matching
The simple scheme uses with two wild cards, '<' and '>' (these wild cards can be changed using SetMatchChars   ):

   '<' matches any run of characters at the start of a key

   '>' matches any run of characters at the end of a key

Thus:

   'hello there'    matches   'hello there'    but   'Hello There'    doesn't
   '<there'       matches    'hello there'    but    '<the'       doesn't
   'hello>'       matches   'hello there'   but   'ello>'      doesn't
   '<lo th>'      matches   'hello there'   but   '<loth>'      doesn't

   '<>' matches anything!

Grep-style pattern matching
The grep-style mode uses the following meta-characters:

   '^'    matches only at the beginning of a key
   '%'   matches only at the beginning of a word
   '$'   matches only at the end of a key
   '&'   matches only at the end of a word
   '\'   quotes any character
   '.'   matches any single character
   ':x'   matches any character of class x.
   ':a'   matches any alphabetic character
   ':d'   matches any numeric character
   ':n'   matches any alphanumeric character
   ': '   matches spaces, tabs, and other control characters
   '[...]'    matches any character within the brackets
   '[^...]'   matches any character but the ones which follow '^' within in the brackets


If you wish to employ a more elaborate matching scheme you can override the protected functions SimpleMatches and GrepMatches.

Robert R. Marsh, SJ & the British Province of the Society of Jesus