Global
Returns or sets whether all matches are used, or only the first.
Get
Returns a Boolean.
Syntax: object.Global
- object
- required An object expression that evaluates to a RegExp.
The default value is False.
Let
Sets the value.
Syntax: object.Global = value
- value
- A Boolean. True makes Execute return every match, Replace replace every match, and Split split at every match. False makes each of them use only the first match.
Remarks
Test does not depend on the value, because it only reports whether a match exists.
The value is applied when a match is made. Changing it does not compile the pattern again. The flag g of Flags reads and sets the same value.
Example
Dim re As RegExp
Set re = New RegExp
re.Pattern = "\d+"
Debug.Print re.Execute("a1b22c333").Count ' 1
Debug.Print re.Replace("a1b22c333", "#") ' a#b22c333
re.Global = True
Debug.Print re.Execute("a1b22c333").Count ' 3
Debug.Print re.Replace("a1b22c333", "#") ' a#b#c#