ASP gets the function of the top-level domain name in the address URL

Source: Internet
Author: User
Tags filter end split domain domain name
ASP to get the Address bar URL in the top-level domain name function, not regular, very practical, personal debugging and easy to use.

In the production of a DLL component, because the DLL is not convenient to call the regular function, so, the production of a do not need to get the function with the domain name, contribute to everyone!

The following is the program code private Function durl (URL)
Dim domext, S1, S2, Re, matches, Arrdom, DD
Domext = "comnetorgcnlaccinfohkbizmemobinametvasiakrdeorg.cnco.krcom.cnnet.cngov.cn"
Arrdom = Split (Domext, "")
Durl = "": url = LCase (URL)
If url = "" Or Len (URL) = 0 Then Exit Function
url = replace (replace (URL, "http://", ""), "https://", "")
S1 = InStr (URL, ":")-1 ' Filter off port
If S1 < 0 Then S1 = InStr (URL, "/")-1 ' filter off/back characters
If s1 > 0 Then url = Left (URL, s1)
S2 = Split (URL, ".") (UBound (Split (URL, "."))
If InStr (domext, s2) = 0 Then
Durl = URL
Else
For dd = 0 to UBound (arrdom)
If InStr (URL, "." & Arrdom (dd)) > 0 Then
Durl = Replace (URL, "." & Arrdom (DD) & "", "")
If InStr (Durl, ".") = 0 Then
Durl = URL
Else
Durl = Split (Durl, ".") (UBound (Split (Durl, ".")) & "." & Arrdom (DD)
End If
End If
Next
End If
End Function



Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.