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