regex.split problem

mmi

Member
Licensed User
Longtime User
Hi,

I found this example of using regex.split on the forum.
-------------
Dim text As String
text= "1,2,3,4,5,6"
Dim tempstr() As String
tempstr = Regex.Split(",", text)
label1.Text = tempstr
-------------

My problem is that no matter what I do i keep getting errors when trying to remove any of the characters:
[Ljava.lang.String;@43e48078 etc.

I'm only trying to break up a string of text e.g. 1,2,3,4,5,6 and display it without the commas.

Can anyone please help!
MMI
 

klaus

Expert
Licensed User
Longtime User
B4X:
Dim text As String
text= "1,2,3,4,5,6"
Dim tempstr() As String
tempstr = Regex.Split(",", text)
In your example, with Regex.Split you get an array of 6 characters.
tempstr(0) = 1
tempstr(1) = 2
tempstr(1) = 3
etc.

To remove the "," you must use :
B4X:
text= "1,2,3,4,5,6"
text = text.Replace(text, ",")
label1.Text = text
Best regards.
 
Upvote 0

mmi

Member
Licensed User
Longtime User
Hi Klaus,

I did want the array and forgot to add the array index number i
label1.text = tempstr(i)

B4X:
'SOLUTION
Dim text As String
    text = "1,2,8,4,5,6"
    Dim tempstr() As String
    tempstr = Regex.Split(Chr(44), text)
    label1.Text = tempstr(2)



Thanks for the quick reply.
mmi
 
Upvote 0

Similar Threads

Top