VB.NET URL Parsing

A URL, which stands for Uniform Resource Locator, serves as the universal address for locating a specific document or resource on the internet. It provides a standardized format for identifying and accessing web pages, files, and other online content.

In VB.NET program, we can check whether a URL exists within a given string. This can be achieved using the Regex.IsMatch method, which enables us to search for a specific pattern within the input string.


Regex.IsMatch(inputString, patternString) method

By using the Regex.IsMatch(inputString, patternString) method, we can evaluate whether a URL is present in the input string. The patternString parameter represents the regular expression pattern that defines the structure and format of a URL. The method returns a Boolean value indicating whether a match is found or not.

This approach allows developers to efficiently identify and extract URLs from a larger string, enabling further processing or validation of the identified URLs within their VB.NET programs.

Full Source VB.NET
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 = "https://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