Friday, September 16, 2011

Validate URL

   Dim pattern As String = "^(http|https):/{2}[a-zA-Z./&\d_-]+"
        'create a new RegEx object
        Dim reg As New Regex(pattern, RegexOptions.IgnoreCase Or RegexOptions.ExplicitCapture)
        If reg.IsMatch(TextBox1.Text) = False Then
            MsgBox("invalid url!")
        Else
            MsgBox("valid url!")
        End If

No comments:

Post a Comment