M mmi Member Licensed User Longtime User May 2, 2012 #1 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
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 May 2, 2012 #2 Code: Copy 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 : Code: Copy text= "1,2,3,4,5,6" text = text.Replace(text, ",") label1.Text = text Best regards. Upvote 0
Code: Copy 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 : Code: Copy text= "1,2,3,4,5,6" text = text.Replace(text, ",") label1.Text = text Best regards.
M mmi Member Licensed User Longtime User May 2, 2012 #3 Hi Klaus, I did want the array and forgot to add the array index number i label1.text = tempstr(i) Code: Copy '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
Hi Klaus, I did want the array and forgot to add the array index number i label1.text = tempstr(i) Code: Copy '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