From: Guillaume Carbonneau Date: 2006-07-27T00:30:25+09:00 Subject: Re: gsub ------=_Part_24955_21901136.1153927822113 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, what you really want to use if you want a clean solution is negative lookaheads built into your regular expression. How lookaheads work: http://www.regular-expressions.info/lookaround.html Search google for specific lookahead uses in Ruby as I haven't experienced them yet with this language. On 7/26/06, Tomas Fischer wrote: > > Hi, > > I have a string s= XXaaXX, in which i want to replace the last substring > r, which is determined at run time. > > r= XX > > s.gsub(/XX\z/,'') solves the problem in a static way. > s.gsub(r,'') solves it too, but who can I specify, that only the last > occurence should be replaced. > > Best regards, > Tomas > > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_24955_21901136.1153927822113--