Android Question Split a string into two variables...

select

Member
Licensed User
Longtime User
Hello, I've this problem. I'm trying to split a string (obtained from a sql sentence) in two variables.

The values in the string are separated by comma, something like:

B4X:
"Car    ,Red  "

I would like to enter "Car" in a variable "A" and "Red" in a variable "B".

I tried with "regex.split" without success.

Does anyone know how to do this?

tnx
 

Andrew Gray

Member
Licensed User
Longtime User
What if you want to split a string into ONLY two?

Is there a function that would take "car, red, vintage, diesel" and return "car" in one variable and "red, vintage, diesel" in the other?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Is there a function
No. But nobody stop you to create such a function. As you already know how to split a string it should be easy to build yourself a small helper-sub which splits a string and build two returnvalues. As a sub only can return one value i suggest using a list or a map as returnvalue.
 
Upvote 0
Top