From: Wilson Bilkovich Date: 2007-01-17T05:50:03+09:00 Subject: Re: External to internal conversion On 1/16/07, Peter Versteegen wrote: > Wilson, > > I was looking more for an output like [[25.0, 26], [30, 31]], an aray > of two arrays. > > Thanks, > Probably easiest to do it in two steps, since bracket-matching is a real chore in a regular expression. >> input = "[25.0, 26], [30, 31]" => "[25.0, 26], [30, 31]" >> groups = input.scan(/\[.*?\]/) => ["[25.0, 26]", "[30, 31]"] >> output = groups.map {|g| g.scan(/\d+\.?\d*/).map {|n| n.to_i} } => [[25, 26], [30, 31]] Do you really need 25.0 instead of 25? Mixing integers and floats can be a bad idea. Adjust the 'to_i' call accordingly.