From: "Peña, Botp" Date: 2008-03-03T16:19:34+09:00 Subject: Re: Split the string On Behalf Of Sijo Kg: # This is of the form # 3:43;SD,2:65;SD,3:50;Inc # How can i split this to get # =>[["3","43","SD"],["2","65","SD"],["3","50","Inc"]] #... # Here i have to get the first 2 fields as integer and the third as # string read on split, arrays, and enumerators. this is just a simple example, irb(main):037:0> require 'enumerator' => false irb(main):038:0> s="3:43;SD,2:65;SD,3:50;Inc" => "3:43;SD,2:65;SD,3:50;Inc" irb(main):039:0> a=[] => [] irb(main):040:0> s.split(/,|:|;/).each_slice(3){|x| a << [x[0].to_i,x[1].to_i,x[2]]} => nil irb(main):041:0> a => [[3, 43, "SD"], [2, 65, "SD"], [3, 50, "Inc"]] kind regards -botp