Android Question String Functions - Split Behavior

ansoUzr

Member
Licensed User
Longtime User
I have a string s = "a,,,". If I use ... SF.Split(s,",") the length of the returned list is 2. If I change to "s= a, , ," the returned length is 3. I would have thought both would have returned a length of 4. Am I missing something? (For comparison: Visual Basic Split Function returns 4.)

William
 

ansoUzr

Member
Licensed User
Longtime User
Thanks. I should have caught that.

Trailing empty matches are removed (see the documentation).
B4X:
Dim s() As String = Regex.Split(",","a,,,") '1
Log(s.Length)
Dim s() As String = Regex.Split(",","a,,, ") '4
Log(s.Length)
 
Upvote 0
Top