string split function

gjoisa

Active Member
Licensed User
Longtime User
I can't find string split function . How to get it ? for eg:
B4X:
dim temp as string
dim rst() as string
temp = "Ravi,Hari,Raman,Anitha,Vinod"
rst = Split(temp,",")
Actually array variable rst shoud get splitted strings from temp .
P.S: Last line in code does not work .
 

Theera

Well-Known Member
Licensed User
Longtime User
I can't find string split function . How to get it ? for eg:
B4X:
dim temp as string
dim rst() as string
temp = "Ravi,Hari,Raman,Anitha,Vinod"
rst = Split(temp,",")
Actually array variable rst shoud get splitted strings from temp .
P.S: Last line in code does not work .

Example:
Dim components() As String
components = Regex.Split(",","abc,def,,ghi") 'returns: "abc", "def", "", "ghi"

components(0)="abc"
components(1)="def"
components(2)=""
components(3)="ghi"
 
Last edited:
Upvote 0

cbal03

Member
Licensed User
Longtime User
Split appears to behave incorrectly

Dim strVersion As String
Dim lstVersions As List


strVersion = "1,0,0a"
lstVersions = Regex.Split(",",strVersion) 'list items seperated by comma.
Log("Split version: " & strVersion) 'show original string
Log(lstVersions) 'show list contents

output:
(ArrayList) [1, 0, 0a]

The above works fine. However when I use a dot for the seperating text the list isn't filled. Like below.


Dim strVersion As String
Dim lstVersions As List


strVersion = "1.0.0a"
lstVersions = Regex.Split(".",strVersion) 'list items seperated by dot.
Log("Split version: " & strVersion) 'show original string
Log(lstVersions) 'show list contents - LIST IS EMPTY?

output:
(ArrayList) []


Thanks in advance!
 
Last edited:
Upvote 0
Top