From: Christopher Swasey Date: 2008-03-03T15:37:37+09:00 Subject: Re: Split the string On 3/3/08, Sijo Kg wrote: > Sir > > Here i have to get the first 2 fields as integer and the third as > string.Could u please tell how can i do that in the map? Not so elegantly. Map doesn't come in handy here because the string would get converted to a 0. What you can do is hold the split inside a temporary variable and construct another array, as such: arr = "3:43;SD,2:65;SD,3:50;Inc".split(/,/).map do |i| t = i.split(/:|;/) t[0..1].map { |j| j.to_i } << t[2] ### If you're using Rails you can use Symbol#to_proc to simplify the code # t[0..1].map(&:to_i) << t[2] ### or something very simple, if a tiny bit repetitive: # [t[0].to_i, t[1].to_i, t[2]] end => [[3, 43, "SD"], [2, 65, "SD"], [3, 50, "Inc"]] Christopher