|
|
|
NOTE: This Design document is subject to change at any time. |
Tries to match the regular expression RegExp with the Source string. If there is a match, the position of the match is returned, and any substrings captured by the regular expression are stored in the Matches collection. If there is no match, then a zero is returned. The Options argument allows you to control items like case sensitivity. See the Options list for more details. The match is performed beginning at the Start position of the Source string.
Matches is a zero-based collection. The Matches[0] value returns the entire portion of Source that matched the pattern. Matches[1]..Matches[N] contain the subpatterns from RegExp that were surrounded with parenthesis.
If Options is omitted, no options are applied. If Start is omitted, the match starts at the beginning of the Source string.
zApp saves the previous compiled regular expression so if you call Match with the same pattern but different source strings or start positions, the second execution will be faster than the first.
For example:
str.Match("(\d+) gold", "123 gold", Matches, "", 1)
returns a value of 1 since it matches the beginning of the string. And the collection Matches has two items stored in it: Matches[0] is "123 gold" and Matches[1] is "123".
JScript Note: JScript does not support by-reference arguments, so you cannot access Matches within JScript and should not use this function. |
|