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.

-- 
http://www.mikrocontroller.net - Das Mikrocontroller-Forum