设置或返回一个 Boolean 值,该值指明在整个搜索字符串时模式是全部匹配还是只匹配第一个。
object.Global [= True | False ]
对象 参数总是 RegExp 对象。如果搜索应用于整个字符串,Global 属性的值为 True,否则其值为 False。默认的设置为 False。
下面的代码说明了 Global 属性的用法(改变赋予 Global 属性的值并观察其效果):
Function RegExpTest(patrn, strng)
   Dim regEx ,match,matches   ' 建立变量。
   Set regEx = New RegExp   ' 建立规范表达式。
   regEx.Pattern = patrn   ' 设置模式。
   regEx.IgnoreCase = True   ' 设置是否区分字母的大小写。
   regEx.Global = True   ' 设置全程性质。
   set matches= regEx.Execute(strng)   ' 执行搜索。
   for each match in matches      ' 重复匹配集合
      RetStr=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"))
应用于:RegExp 对象