Asp detection URL positive expression
<% Function IsValidUrl (UrlValue)
Dim ArrayUrl, thisUrl, PostFix, url
Dim I, x, y, c
IsValidUrl = True
ArrayUrl = Split (UrlValue, "| ")
For I = 0 to UBound (ArrayUrl)
ThisUrl = Split (ArrayUrl (I ),".")
If UBound (thisUrl) <0 then' check whether there is any.
IsValidUrl = False
Exit Function
End if
PostFix = UBound (thisUrl) '.
If IsValidPostFix (thisUrl (PostFix) = False then' check whether the region is com, net, or cn. You can add it to the IsValidPostFix function according to the actual situation.
IsValidUrl = False
Exit Function
End if
For each url in thisUrl
If Len (url) <= 0 then
IsValidUrl = False
Exit Function
End if
If InStr (url, "-") = 1 then', the first letter cannot start "-"
IsValidUrl = False
Exit Function
End if
For y = 1 to Len (url)
C = Lcase (Mid (name, y, 1 ))
If InStr ("abcdefghijklmnopqrstuvwxyz _-", c) <= 0 and IsNumeric (c) = False then' can be any English or number
IsValidUrl = False
Exit Function
End if
Next
If Left (url, 1) = "." or Right (url, 1) = "." then
IsValidUrl = False
Exit Function
End if
Next
Next
End Function
'Timeout '-----------------------------------------------------------------------------------------------------------
Function IsValidPostFix (PostFixValue)
Dim ValidPostFix, thisPostFix
Dim k
IsValidPostFix = False
ValidPostFix = "com, net, cn"
ThisPostFix = Split (ValidPostFix ,",")
For k = 0 to UBound (thisPostFix)
If Instr (PostFixValue, thisPostFix (k)> 0 then
IsValidPostFix = True
Exit Function
End if
Next
End Function
'Timeout '-----------------------------------------------------------------------------------------------------------
'Timeout '-----------------------------------------------------------------------------------------------------------
Response. Write IsValidUrl ("abc.com.cn & brvbar; abc.com & brvbar; bbs.news.163.com ")