Using Regex method Replace: String split at commas
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")
Dim resultString As String
Console.WriteLine("String split at commas" & vbTab & _
vbTab & "[")
For Each resultString In Regex.Split(testString2, ",\s*")
Console.WriteLine("""" & resultString & """, ")
Next
End Sub ' Main
End Class
Related examples in the same category