Net-informations.com
SiteMap  | About    

VB.NET URL Parsing

URL stands for Uniform Resource Locator. A URL is the global address for a document or resource on the internet. A sample URL is given below.

  http://vb.net-informations.com

The following VB.NET program checking whether a URL exist in the string or not. Here we are using Regex.IsMatch(inputString,patternString) method to find the URL in a string




Imports System.Text.RegularExpressions

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pattern As String
        Dim urlStr As String = "http://net-informations.com"
        pattern = "http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?"
        If Regex.IsMatch(urlStr, pattern) Then
            MsgBox("Url exist in the string ")
        Else
            MsgBox("String does not contain url ")
        End If
    End Sub
End Class






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.