bool = MatchPattern(src$, pattern$)
src$
matches the pattern
specified in pattern$
. If it does, True
will be returned, else False
.
MatchPattern()
will compare pattern$
to src$
character by character and
abort as soon as it finds a difference. If it does not find a difference,
it will return True
.
The pattern specified in pattern$
is a string that can contain normal
characters and wildcards. A wildcard is a special character that can
be used to match more than one character in the source string. The
following wildcards are currently supported:
*
?
#
[]
a
, whereas [af] matches
a
and f
and [a-f] matches all characters in the range of a
to f
.
You can use the '!' prefix to negate the result, i.e. [!a] matches
every character except a
.
You can also combine multiple patterns in a single string by separating them using a semicolon.
If you need more sophisticated pattern matching, have a look at the PatternFindStr() function. See PatternFindStr for details.
True
if string matches the pattern or False
r = MatchPattern("Pictures/JPG/Pic1.jpg", "*.jpg")Returns
True
because the string matches the pattern.
r = MatchPattern("Pictures/JPG/Pic1.gif", "*.jpg;*.gif")Returns
True
because the string matches the pattern.
r = MatchPattern("Hollywood 2.a", "Hollywood #.#")Returns
False
because a
does not match the numeric wildcard (#).