From: "Eric I." Date: 2008-06-02T00:59:31+09:00 Subject: Re: Remove Parts of a String On Jun 1, 11:33 am, Dan __ wrote: > Thanks very much Stefano :)  Thats exactly what I wanted, and it works > great :) > -- > Posted viahttp://www.ruby-forum.com/. Hi Dan, You're the expert in your the domain, and I obviously don't understand the larger picture. But the idea of getting access to the data after the colons at a later stage using indexing into the original string sounds unnecessarily complex. So here's another approach. If you run this, you'll see what you get at every step. ==== s = "12343:3,73820:1,183874:8" # break it up into an array of arrays of strings a = s.split(',').map { |v| v.split(':') } p a # now you can do lots of things # just want the numbers before the colons? b1 = a.map { |v| v.first } p b1 # want them as integers rather than strings? b2 = a.map { |v| v.first.to_i } p b2 # want it as a string w/ commas? this seems to be part of your original request b3 = a.map { |v| v.first }.join(',') p b3 # want to regenerate the original string? b4 = a.map { |v| v.join(':') }.join(',') p b4 ==== Maybe (or maybe not) that's helpful.... Eric ==== LearnRuby.com offers Rails & Ruby HANDS-ON public & ON-SITE workshops. Ruby Fundamentals Wkshp June 16-18 Ann Arbor, Mich. Ready for Rails Ruby Wkshp June 23-24 Ann Arbor, Mich. Ruby on Rails Wkshp June 25-27 Ann Arbor, Mich. Ruby Plus Rails Combo Wkshp June 23-27 Ann Arbor, Mich Please visit http://LearnRuby.com for all the details.