From: Robert Dober Date: 2006-07-26T23:07:21+09:00 Subject: Re: gsub ------=_Part_24982_31314484.1153922836652 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/26/06, Tomas Fischer wrote: > > Hi, > > thanks for your solutions. But I've forgotten to mention, that r can > contain brackets, so the simple way s.gsub(/#{r}$/,'') doesn't work. > > I use now the reverse, sub approach. > > Best regards, > Tomas > > -- > Posted via http://www.ruby-forum.com/. > > Well Thomas if your pattern is really at the end of the string you can use the -- much faster -- anchoring approach Vincent suggested, just escape your regexp and use sub instead of gsub as pointed out by Edward in case there is only one line. s.sub %r{#{Regexp.escape(r)}$}, "" Robert ------=_Part_24982_31314484.1153922836652--