How to split a string with multiple separators in VB.NET

1 Answer

0 votes
Imports System

Class SplitExample
    Public Shared Sub Main()
        Dim input As String = "abc,defg;hijk|lmnop-qrst_uvwxyz"
        
		Dim result As String() = System.Text.RegularExpressions.Regex.Split(input, "[,;|\-_]")

        For Each word As String In result
            Console.WriteLine(word)
        Next
    End Sub
End Class



' run:
' 
' abc
' defg
' hijk
' lmnop
' qrst
' uvwxyz
'

 



answered Jul 21, 2025 by avibootz
...