> This issue is mentioned in 'Programming Ruby', "Standard Types" chapter
> (see http://www.rubycentral.com/book/).

As I said, I figured it was a bit of a newbie question :-).  I read PR chapter 
18 months ago, but presumably haven't needed to use that specific piece of 
information up until now ... and that my brain doesn't have enough spare 
capacity :-).

> The problem is that you can use \&, \1 \2 etc. in the replacement string to
> match groups, so gsub is gobbling up your \\.

That makes sense.

> The solution is to either do
> 	x.gsub("'", "\\\\'")
> or
> 	x.gsub("'") { "\\'" }
>
> The latter form works because when given a block, groups are given as
> arguments to the block instead of using \1, \2 etc, so gsub doesn't have to
> touch \'s in the replacement string.

Thanks.  I'll go and re-read the section of PR you mentioned, anyway.

Cheers.