Asp detection URL positive expression

Source: Internet
Author: User

 

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 ")

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.