From: Jan Svitok Date: 2006-07-22T02:17:32+09:00 Subject: Re: Replacing ' with \' using gsub Seems to me like a bug in the regex code. using ruby 1.8.4 (2005-12-24) [i386-mswin32] J. On 7/21/06, Jani Soila wrote: > I tried to replace "'" characters with "\'" strings using gsub. What > happened instead was something completely different. Am I missing > something here? > (in irb) > irb(main):001:0> s = "a'b'" > => "a'b'" > Unexpected result > irb(main):002:0> s.gsub(/'/, "\\'") > => "ab'b" > Also with this > irb(main):003:0> s.gsub(/'/, '\\\'') > => "ab'b" > However this works > irb(main):004:0> s.gsub(/'/, "\\x'") > => "a\\x'b\\x'" > > Thank you for your help! > -js > > -- > Posted via http://www.ruby-forum.com/. > >