From: Ammar Ali Date: 2010-11-22T08:27:06+09:00 Subject: Re: gsub and backslashes On Sun, Nov 21, 2010 at 11:02 PM, Brian Candler wrote: > Ralph Shnelvar wrote in post #962847: >>   "\\1\\2\\3".gsub(/\\/,"\\\\") > > Here you are replacing one backslash with one backslash. > > The trouble is, in the *replacement* string, '\1' has a special meaning > (insert the value of the first capture). Because of this, a literal > backslash is backslash-backslash. That's a keen observation, but the fact that they happen to be back-references doesn't seem to play a part in this situation. >> "\\a\\b\\c".gsub(/\\/,"\\\\") => "\\a\\b\\c" >> "\\a\\b\\c".gsub(/\\/,"\\\\\\") => "\\\\a\\\\b\\\\c" Regards, Ammar