From: Mitch Date: 2005-08-16T00:30:32+09:00 Subject: Re: utf8 string with reverse question Aha, I knew there was something I was missing in Regexp. Thanks for confirming. :) I will get back to my program after work today. Thanks, Mitch On 8/15/05, Pit Capitain wrote: > Mitch Tishmack schrieb: > > In short I see this behavior: > > > > "Stuhlu".sub(/u/,'�') > > => "St�hlu" > > "Stuhlu".reverse.sub(/u/,'�').reverse > > => "Stuhl\274\303" > > "Stuhlu".reverse.sub(/u/,'�').split(//).reverse.join > > => "Stuhl�" > > > > The general goal is to sub the final "u" in that word with an umlauted > > version and not the first. > > ... > > Am I mising a > > Regexp option that would make the final match work? > > Can't help with the reverse behaviour, but if you want to substitute > single letters only the following regexp should work: > > "Stuhlu".sub(/u(?=[^u]*$)/,'�') > > Regards, > Pit > >