Global attributes
Set or returnBooleanValue, which indicates whether the pattern matches all or only the first character in the entire search string.
object.Global [= True | False ]
Object parameters alwaysRegExpObject. If the search is applied to the entire string,GlobalThe property value isTrueOtherwise, the value isFalse. The default value isFalse.
Description
The following code illustratesGlobalAttribute usage (change to assignGlobalAttribute Value and observe its effect ):
Function RegExpTest(patrn, strng) Dim regEx ,match,matches '
Create a variable. Set regEx = New RegExp '
Create a regular expression. regEx.Pattern = patrn '
Set the mode. regEx.IgnoreCase = True '
Specifies whether to distinguish between uppercase and lowercase letters. regEx.Global = True '
Set the full nature.set matches= regEx.Execute(strng) '
Execute the search.for each match in matches '
Repeated matching setRetStr=RetStr &"Match found at position "
RetStr=RetStr&Match.FirstIndex&".Match Value is '"
RetStr=RetStr&Match.Value&"'."&vbCRLF Next
RegExpTest=RetStr
End Function
MsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))