Regex Pattern to Validate URL

Posted by Bugwee under VB.NET category on | Points: 40 | Views : 14864
        'regex pattern for validating
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(txtURL.Text) = False Then
MsgBox("invalid url!")
MsgBox("valid url!")
End If

Comments or Responses

Login to post response