From: Wilson Bilkovich Date: 2007-01-17T03:51:13+09:00 Subject: Re: External to internal conversion On 1/16/07, Peter Versteegen wrote: > Hello All, > > I like to rephrase my problem below by the following interactive > session: > >> x = "1, 12, 500" > => "1, 12, 500" > >> a = x.split(",").map {|k| k.to_i} > => [1, 12, 500] > >> y = "[25.0, 26], [30, 31]" > => "[25.0, 26], [30, 31]" > >> b = y.split(",").map {|k| k.to_i} > => [0, 26, 0, 31] > > I get what I want in the 4th line, an array of numbers > I don't get, nor did I expect to, what I want in the last line, i.e., an > array of arrays. > How can I convert to an array of arrays? > >> input = "[25.0, 26], [30, 31]" => "[25.0, 26], [30, 31]" >> input.scan(/\d+\.?\d*/) => ["25.0", "26", "30", "31"] Something like that?