Using Regex method Replace:\w+
Imports System.Text.RegularExpressions
Imports System
Public Class MainClass
Shared Sub Main()
Dim testString1 As String = "This sentence ends in 5 stars *****"
Dim testString2 As String = "1, 2, 3, 4, 5, 6, 7, 8"
Dim testRegex1 As Regex = New Regex("stars")
Dim testRegex2 As Regex = New Regex("\d")
Console.WriteLine("Original String 1" & vbTab & _
vbTab & vbTab & testString1)
Console.WriteLine("Every word replaced by " & _
"""word""" & vbTab & _
Regex.Replace(testString1, "\w+", "word"))
End Sub ' Main
End Class
Related examples in the same category