On 2013-05-29, at 6:29 AM, Tadeusz Bochan <lists / ruby-forum.com> wrote:

> Ooops. Spoke too soon. The workaround doesn't.
> 
> "xyz#abc".gsub("#","\\043") =>  "xyz#43abc"
> 
> -- 
> Posted via http://www.ruby-forum.com/.

There are a couple of ways to do that:

[1] pry(main)> puts "xyz#abc".gsub("#","\\\\043");
xyz\043abc
[2] pry(main)> puts "xyz#abc".gsub("#") { '\\043' };
xyz\043abc

There's an explanation of how the replacement string is double interpolated at http://www.ruby-forum.com/topic/143645

Hope this helps,

Mike

-- 

Mike  Stok <mike / stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.