VB.NET Regex

Regex handles complex string processing. With the Regex type, you can use a text-processing language to handle these cases with much less VB.NET code. This may come with a loss of performance.
This page covers VB Regex Functions. It has many examples for System.Text.RegularExpressions.

This simple program demonstrates the Regex type in the VB.NET language. Please notice how the System.Text.RegularExpressions namespace is included at the top. The Regex pattern "\d+" matches one or more digit characters together. If the match is successful, we print its value, which is "77".
Program that uses System.Text.RegularExpressions [VB.NET]
Imports System.Text.RegularExpressions
Module Module1
Sub Main()
Dim regex As Regex = New Regex("\d+")
Dim match As Match = regex.Match("Dot 77 Perls")
If match.Success Then
Console.WriteLine(match.Value)
End If
End Sub
End Module
Output
77
For complex text replacements and matching, nothing beats the Regex type in the VB.NET programming language. You can specify complex patterns using the text-processing language embedded in the Regex type. We provide specific examples that can be adapted to your programs.
Remove HTML Tags Word Count FunctionMatch function examples. The Match, Matches and IsMatch functions are used to locate and return parts of the source String in separate variables. To capture groups, you can use parentheses in your Regex pattern.
Regex.Match Regex.Matches Regex.Matches Quote Example Regex.IsMatchReplace function examples. Replace, which can take an optional MatchEvaluator argument, will perform both a matching operation and a replacement of the matching parts based on the arguments you specify.
Regex.Replace Regex.Replace Uses MatchEvaluator
Split function example. Sometimes, the String Split function is just not enough for your splitting needs in the VB.NET language. For these times, try the Regex.Split function.
Regex.Split
In some programs, using Regex functions is the simplest and easiest way to process text. In others, it just adds additional complexity for little gain. With the examples in this section, we learn when to best apply these functions.