Dim strOk,strNo strOk = "12312321$12312312312$12312321$" strNo = "12312321$12312312312$12312321$sdfsd"
Function RegExpTest(patrn, strng) Dim regEx, match, matches ' 建立變量。 Set regEx = New RegExp ' 建立規范表達式。 regEx.Pattern = patrn ' 設置模式。 regEx.IgnoreCase = True ' 設置是否區分字母的大小寫。 regEx.Global = false ' 設置全程性質。 set matches= regEx.Execute(strng) ' 執行搜索。 for each match in matches ' 重復匹配集合 RetStr=RetStr "Match found at position " RetStr=RetStrMatch.FirstIndex".Match Value is '" RetStr=RetStrMatch.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))