ASP gets URL address function in string

Source: Internet
Author: User

ASP tutorial get URL address function in string
This article provides three uses ASP's regular obtains the URL address custom function Oh, the three method realization principle all is obtains HTTP to open the URL address Oh.
On Error Goto Z

Dim url,key,wwwname
Url=request.servervariables ("SERVER_NAME")
If InStr (URL, ".") >0 Then
Key=split (URL, ".")
Wwwname=key (0)
Wwwname=replace (Wwwname, "http://", "")
End If
Response.Write (Wwwname)

Method Two

' VB.net:
Public Shared Function Isurl (ByVal strtmp As String) As Boolean
On Error Goto Z
Dim objintpattern As New System.Text.RegularExpressions.Regex ("^ (Http://|https Tutorial://) {0,1}[a-za-z0-9][a-za-z0-9-.] +[A-ZA-Z0-9]. [A-za-z] {2,} [43-176]*$ "]
Return Objintpattern.ismatch (strtmp)
Z:
End Function

Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox (Isurl ("http://www.sohu.com"))
Method Three

Dim Objintpattern
Isurl = False
Set Objintpattern = new RegExp
Objintpattern.pattern = "^ (http://|https://) {0,1}[a-za-z0-9][a-za-z0-9-.] +[A-ZA-Z0-9]. [A-za-z] {2,} [43-176]*$]
Objintpattern.global = True
Isurl = Objintpattern.test (strtmp)
Set Objintpattern = Nothing
Z:
End Function

Private Sub Command1_Click ()
MsgBox Isurl ("http://www.sohu.com")
End Sub

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.