From: S2 Date: 2008-03-04T00:05:05+09:00 Subject: Re: Split the string 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"]] > > Sijo z = Array.new "3:43;SD,2:65;SD,3:50;Inc".split(',').each {|n| z << n.split(/:|;/)} z => [["3", "43", "SD"], ["2", "65", "SD"], ["3", "50", "Inc"]]