Regular expressions come handy when we have this kind of requirement. Regex.Replace method can be used remove the unwanted text






















Visual Studio .NET Tips and Tricks, VB.NET Code Samples, C# Code Snippets, ASP.NET Code Samples, .NET Tips and Tricks, C# Tips & Tricks, Visual Studio 2010, .NET Framework Code Samples, VB.NET Tips & Tricks
Sub Regex_Checker_Duplicate_Words()
Dim oRegex As Regex
Dim sPattern As String
Dim oMatches As Match
Dim sText As String
sText = " the the category catastropic cat cat and rat b b "
sPattern = "\b([a-zA-Z]+)\s+\1"
oRegex = New Regex(sPattern)
oMatches = oRegex.Match(sText, sPattern)
While oMatches.Success
MsgBox(oMatches.Groups(0).Value.ToString)
oMatches = oMatches.NextMatch
End While
End Sub
Returns a new Match with the results for the next match, starting at the position at which the last match ended (at the character beyond the last matched character).
Extract Ref Links From WebPage using VB.Net Regular Expressions
Remove HTML Tags from String using .NET Regular Expressions
VB.NET Regular Expression to Check URL
VB.NET Regular Expression to Check Email Addresses
VB.NET Regular Expression to Check MAC Address
Regular Expression to Check Zip Code
Validate eMail Addresses using VB.NET Function
Regular Expressions in Dot Net (.NET)