From: Michael Fellinger Date: 2008-03-03T17:02:00+09:00 Subject: Re: Split the string 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"]] ^ manveru