Split string

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hi,
I have this string; 108-306-204..
How can I get:
a = 108
b = 306
c = 204
??
 

Mahares

Expert
Licensed User
Longtime User
Here it is:
B4X:
Dim strBeforeSplit As String 
strBeforeSplit="108-306-204"
Dim strSplit() As String
strSplit=Regex.Split("-",strBeforeSplit)
Msgbox(strSplit(0) &  "  " & strSplit(1) &  "  " & strSplit(2),"")   'returns: 108  306  204
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Here it is:
B4X:
Dim strBeforeSplit As String 
strBeforeSplit="108-306-204"
Dim strSplit() As String
strSplit=Regex.Split("-",strBeforeSplit)
Msgbox(strSplit(0) &  "  " & strSplit(1) &  "  " & strSplit(2),"")   'returns: 108  306  204

It doesn't help me, because I need each value different time!
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
That is simple. All you need to do is equate your variables to the different array components like this:
a=strSplit(0)
b=strSplit(1)
c=strSplit(2)
 
Last edited:
Upvote 0

paolofi

Member
Licensed User
Longtime User
HI,
why this works:

B4X:
Dim Valore As String
Dim strSplit() As String
   
Value = "6-03/12/2012-test"      '<--------------
   
strSplit=Regex.Split("-",Value )

Msgbox(strSplit(0) &  "  " & strSplit(1) &  "  " & strSplit(2),"")

and this not?

B4X:
Dim Valore As String
Dim strSplit() As String
   
Value = "6|03/12/2012|test"    '<--------------
   
strSplit=Regex.Split("|",Value )

Msgbox(strSplit(0) &  "  " & strSplit(1) &  "  " & strSplit(2),"")

the "|" symbol is reserved?.

Regards
 
Upvote 0
Top