From: Anurag Priyam Date: 2011-01-14T04:33:53+09:00 Subject: Re: Retrieving and copying element from array > ["category: cat1", >  "item1, item2, item3", >  "category: cat2", >  "item1", >  "category: cat3", >  "item1, item2, item3, item4",] > > How can I have a new array like this: > > [["cat1", "item1", "item2", item3"], >  ["cat2", "item1"], >  ["cat3", "item1", "item2", "item3", "item4"] > ] > If your initial array is called 'list' : >> result = [] >> list.each_slice(2) {|i, j| result.push(i.sub(/category: /, '')); b.push(*j.split(', '))} Iterate over your list in pairs (each_slice), and remove 'category: ' from the first element, while split the second element over ', ' and append the result to an array. -- Anurag Priyam http://about.me/yeban/