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.

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 = ""
        pattern = "http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?"
        If Regex.IsMatch(urlStr, pattern) Then
            MsgBox("Url exist in the string ")
            MsgBox("String does not contain url ")
        End If
    End Sub
End Class (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About