Dim strOk,strNo strOk = "12312321$12312312312$12312321$" strNo = "12312321$12312312312$12312321$sdfsd"
Function RegExpTest(patrn, strng) Dim regEx, match, matches ' 建立變量。 Set regEx = New RegExp ' 建立規(guī)范表達式。 regEx.Pattern = patrn ' 設(shè)置模式。 regEx.IgnoreCase = True ' 設(shè)置是否區(qū)分字母的大小寫。 regEx.Global = false ' 設(shè)置全程性質(zhì)。 set matches= regEx.Execute(strng) ' 執(zhí)行搜索。 for each match in matches ' 重復匹配集合 RetStr=RetStr &"Match found at position " RetStr=RetStr&Match.FirstIndex&".Match Value is '" RetStr=RetStr&Match.Value&"'."&vbCRLF Next IF Not IsEmpty(matches) And matches(0).Value = strng Then RegExpTest = true Else RegExpTest = false End IF End Function MsgBox(RegExpTest("[/d+/$]+", strOk))