From: Robert Klemme Date: 2004-05-31T20:53:45+09:00 Subject: Re: gsub!, replace with \' "Simon Strandgaard" schrieb im Newsbeitrag news:20040530221337.39b1ecfa.neoneye@adslhome.dk... > Patrick Gundlach wrote: > > Andreas Schwarz writes: > > > > > puts "hello".gsub!(/h/,"\\\\'") > > > > > > "\\" is reserved for backreferences. > > > > Hello Andreas, > > > > Oh, yes. This works fine. Thank you (and of course Simon). > > > > Another way to obtain same result.. without extra escaping. > > puts "hello".gsub!(/h/) {|m| "\\'"} Or >> puts "hello".gsub!(/h/, %q{\\\\'}) \'ello Note: >> puts %q{\\\\'} \\' You need an escaped backslash to prevent interpretation of it in the replacement pattern. robert