用asp實現的匹配:數字$數字$數字$...... 的正則
復制代碼代碼如下:
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=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))