ColdC: Function/Method Reference: match_pattern()


LIST match_pattern(STRING pattern, STRING string)

This function matches the wildcard pattern pattern against string. A wildcard pattern is a string with asterixes (`*') signifying wildcards. A regular character matches itself, while a wildcard matches any number of arbitrary characters. The return value of match_pattern() is a list of the substrings of string which matched the wildcards in pattern, or 0 if the match fails.

match_pattern() allows you to do simple character-based matching. For matching against command formats, however, you should use the match_template() function.

Examples:

match_pattern("*", "foobar")
=> ["foobar"]

match_pattern("foo * bar * baz", "foo quux bar quuux baz")
=> ["quux", "quuux"]

match_pattern("foo * bar", "baz")
=> 0


Last Modified on 24 Mar 1996
Copyright © 1995, 1996, Brandon Gillespie