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

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.