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 ' 遍歷Matches集合。 RetStr = RetStr "Match " I " found at position " RetStr = RetStr Match.FirstIndex ". Match Value is "' RetStr = RetStr Match.Value "'." vbCRLF Next RegExpTest = RetStrEnd FunctionMsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))