From: S2 Date: 2008-03-04T00:04:58+09:00 Subject: Re: Split the string Michael Fellinger wrote: > On Mon, Mar 3, 2008 at 2:31 PM, Sijo Kg wrote: >> I have a string >> @selected_related_model_id_assotype_and_name=params[:relatedidmodelasso] >> >> 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"]] > > require 'scanf' > "3:43;SD,2:65;SD,3:50;Inc".split(',').map do |e| > e.scanf('%d:%d;%s') > end > # [[3, 43, "SD"], [2, 65, "SD"], [3, 50, "Inc"]] but he wants all strings in his array