From: William James Date: 2008-02-23T02:40:00+09:00 Subject: Re: gsub("\\", "\\\\") seems unintuitive On Feb 22, 11:27 am, John Woods wrote: > The following confusing behavior is noted in the pickaxe book (2nd ed) > on page 75: > > # I would expect two backslashes in the result > irb> puts "\\".gsub("\\","\\\\") > \ > > # I would expect four backslashes in the result > irb> puts "\\".gsub("\\","\\\\\\\\") > \\ > > I can certainly work around it, but it seems unintuitive. Is there a > reason why gsub behaves this way? Just curious... puts "\\".gsub("\\"){"\\\\"}