From: Brian Candler Date: 2010-03-01T22:56:59+09:00 Subject: Re: gsub for string Robert Klemme wrote: > You can match arbitrary characters and use capturing groups > > str.gsub(/--([^-]+)--/, '-\\1--1') which you can also do in a block form, which is sometimes clearer and lets you do things like modifying xxxx. str.gsub(/--([^-]+)--/) { "-#{$1}--1" } -- Posted via http://www.ruby-forum.com/.