Piet Versteegen
1/16/2007 8:28:00 PM
Wilson,
I was looking more for an output like [[25.0, 26], [30, 31]], an aray
of two arrays.
Thanks,
Pete Versteegen
On Jan 16, 2007, at 1:51 PM, Wilson Bilkovich wrote:
> On 1/16/07, Peter Versteegen <pversteegen@gcnetmail.net> 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?
>
>