Use Regular Expression to Split string : String Split « Data Type « VB.Net Tutorial






Imports System
 Imports System.Text
 Imports System.Text.RegularExpressions


 Class Tester
     Public Shared Sub Main( )
         Dim s1 As String = "One,Two,Three Four"
         Dim theRegex As New Regex(" |, |,")
         Dim sBuilder As New StringBuilder( )
         Dim id As Integer = 1

         Dim subString As String
         For Each subString In theRegex.Split(s1)
             id = id + 1
             sBuilder.AppendFormat("{0}: {1}" & Environment.NewLine, id, subString)
         Next subString
         Console.WriteLine("{0}", sBuilder)
     End Sub
 End Class
2: One
3: Two
4: Three
5: Four








2.37.String Split
2.37.1.String split by using the Split, String.Split()
2.37.2.Use Regular Expression to Split string
2.37.3.String Split
2.37.4.Use the StringSplitOptions enumeration to include or exclude substrings generated by the Split method.