### Split String

Examples splitting a string in characters.
Example Splitting with no delimiter
Dim str As String ="ABC"
Log($"Example RegEx Split: ${str}"$)
Dim strarr() As String = Regex.Split("",str)
For Each s As String In strarr
Log(s)
Next
Result:
Example RegEx Split: ABC
A
B
C
Example Sub returning Array
`Sub SplitString(del As String, s As String) As String()
Return Regex.split(del, s)
End Sub`
Dim strings() As String = SplitString(";","A;B;C")
For Each s As String In strings
Log(s)
Next
Result:
A
B
C
Get Number of Items from Array
Use property StringArray.Length.
Example:
Dim strings() As String = Regex.Split(";","A;B;C")
Log($"Number of Entries Split: ${strings.Length}"$)
Result:
Number of Entries Split: 3
Get Single Items
Use like:
Dim Strings() as String
Strings(n), where n is between 0 and Strings.length - 1
Example:
Dim strings() As String = Regex.Split(";","A;B;C")
Log($"Number of Strings: ${strings.Length}"$)
Log($"String Number 1 (first item): ${strings(0)}"$)
Output:
Number of Strings: 3
String Number 1 (first item): A
Get Characters from String
Dim TestString As String = "ABC"
Dim Strings() As String = Regex.Split("",TestString)
Log($"Number of Characters in String ${TestString}: ${Strings.Length}"$)
For Each s As String In Strings
Log(s)
Next
Log($"String Number 1 (first item): ${Strings(0)}"$)
Result:
Number of Characters in String ABC: 3
A
B
C
String Number 1 (first item): A

Changed: , Category: RegEx, File: T6C240M1757.htm, ID: 1757