String::Split - unexpected behaviour?
After a comment which was left by Justin Rogers on a recent post of mine I decided to do a bit more testing to confirm the behaviour of String::Split. The documentation has this to say about it:
Identifies the substrings in this instance that are delimited by one or more characters specified in an array
I highlighted the words "or more" in that sentence because I believed that the String::Split method would use all characters to do a split but clearly that ain't the case (see example below) which means that the words "or more" in the help documentation are probably misleading or just plain incorrect.
Dim arr1, arr2 As String()
' a string with "ZY" delimiters Dim text As String = "aaaaZY ddd ZY ZYbbbb" arr1 = Split(text, "ZY") arr2 = text.Split(New Char() {"Z"c, "Y"c})
' Displays 4 , 7 MsgBox(arr1.Length & " , " & arr2.Length)
' a string with "Z" and "Y" characters in it text = "aaaaZ ddd Y Ybbbb" arr1 = Split(text, "ZY") arr2 = text.Split(New Char() {"Z"c, "Y"c})
' Displays 1 , 4 MsgBox(arr1.Length & " , " & arr2.Length)