這邊當然也要補上一篇 ASP 正規表達式的用法
範例 :
<%
Pwd = "9901"
Set RegPwd = new regexp
RegPwd.Pattern = "^\d{6,8}$"
RegPwd.IgnoreCase = true '// 忽視大小寫
if RegPwd.Test(Pwd)=false then
response.write "Password is error !" & "<br>"
else
response.write "Welcome !" & "<br>"
end if
TestStr = "Welcome 16547 to the show!"
Set RegStr = new regexp
RegStr.Pattern = "\d"
RegStr.Global = true
'//true:整個字串進行比對, false:只找出符合的第一個
'//Default 為false
Set MatchObj = RegStr.Execute(TestStr)
For each obj in MatchObj
response.write obj & "<br>"
Next
response.write RegStr.Replace(TestStr,"") & "<br>"
%>
Pwd = "9901"
Set RegPwd = new regexp
RegPwd.Pattern = "^\d{6,8}$"
RegPwd.IgnoreCase = true '// 忽視大小寫
if RegPwd.Test(Pwd)=false then
response.write "Password is error !" & "<br>"
else
response.write "Welcome !" & "<br>"
end if
TestStr = "Welcome 16547 to the show!"
Set RegStr = new regexp
RegStr.Pattern = "\d"
RegStr.Global = true
'//true:整個字串進行比對, false:只找出符合的第一個
'//Default 為false
Set MatchObj = RegStr.Execute(TestStr)
For each obj in MatchObj
response.write obj & "<br>"
Next
response.write RegStr.Replace(TestStr,"") & "<br>"
%>
沒有留言:
張貼留言