Search This Blog

Google Analytics

Wednesday, October 13, 2010

Validate URL using regular expression

Code snippet to validate URL using regular expression in VB.NET language.

Dim s As String = "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+.+\.+[\w\d:#@%/;$()~_?\+-=\\\.&']+)"
Dim o As New System.Text.RegularExpressions.Regex(s)
If o.IsMatch("http://www.google.com") Then
    'GOOD
Else
    'BAD
End If

No comments:

Post a Comment

Do provide your constructive comment. I appreciate that.

Popular Posts