On Sun, 30 May 2004 21:11:18 +0200, Andreas Schwarz wrote:

> Patrick Gundlach wrote:
>> Dear Ruby-hackers,
>> 
>> simple problem: replace a certain letter with \' (backslash apostrophe).
>> 
>> ------------------------------
>> #!/usr/bin/ruby -w
>> puts "hello".gsub!(/h/,"\\'")
>> ------------------------------
>> 
>> result:  elloello
>> 
>> I would like to get:
>> 
>> \'ello
>> 
>> What should I try?
> 
> puts "hello".gsub!(/h/,"\\\\'")
> 
> "\\" is reserved for backreferences.

or 
puts "hello".gsub!(/h/) { %q(\') }

Kristof