From: Robert Klemme Date: 2008-08-08T22:20:47+09:00 Subject: Re: strip with some other character 2008/8/8 Martin DeMello : > On Thu, Aug 7, 2008 at 5:03 PM, Junkone wrote: >> strip function removes the trailing whitespace. i want to remove >> trailing comma's. is there a additional parameter for strip or some >> other function to do the same. > > string.gsub(/^,+/, '').gsub(/,+$/, '') This can be done with a single gsub: irb(main):001:0> s=",,a,," => ",,a,," irb(main):002:0> s.gsub %r{^,+|,+$}, '' => "a" However, both strip trailing and leading commas. So for trailing commas this should be sufficient irb(main):003:0> s.gsub %r{,+$}, '' => ",,a" OP: And of course, use gsub! for inplace modification if you want that. Kind regards robert -- use.inject do |as, often| as.you_can - without end