Using Regex method Replace: ^
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)
testString1 = Regex.Replace(testString1, "\*", "^")
Console.WriteLine("^ substituted for *" & vbTab & _
vbTab & vbTab & testString1)
End Sub ' Main
End Class
Related examples in the same category