asp正則表達式匹配數(shù)字$數(shù)字$數(shù)字$
更新時間:2008年04月26日 21:26:50 作者:
用asp實現(xiàn)的匹配:數(shù)字$數(shù)字$數(shù)字$...... 的正則
復(fù)制代碼 代碼如下:
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 ' 重復(fù)匹配集合
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))
相關(guān)文章
js正則表達式學(xué)習(xí)和總結(jié)(必看篇)
下面小編就為大家?guī)硪黄猨s正則表達式學(xué)習(xí)和總結(jié)(必看篇)。小編覺得挺不錯的,希望對大家有所幫助。一起跟隨小編過來看看吧,祝大家游戲愉快哦2016-11-11