I'm trying to convert a string like this "10|15|1,hi,0,-1,bye,2"
where the first two elements 10|15
mean something different than 1,hi,0,-1,bye,2
. I would like to separate them from each other. A naive way to accomplish that would be:
value = string.split("|");
var first = value[0];
var second = value[1];
var tobearray = value[2];
array = tobearray.split(",");
(Of course, if you know a way to do this in a better way, I'd be glad to know).
However, array
is an array which contains array[0]=1, array[1]=hi, array[2]=0, array[3]=-1
, etc. However, I want to obtain a two dimensional array such as
array[0][0]=1, array[0][1]=hi, array[0][2]=0
array[1][0]=-1, array[1][1]=bye, array[1][2]=2
Is there any way to do that?
Thanks