From: Simon Krahnke Date: 2008-04-24T21:35:09+09:00 Subject: Re: puts "\\".gsub("\\", "\\\\") * martinus (11:53) schrieb: > Hello, I have a mini-ruby quiz. Guess what this line of code writes to > the console, then try it for yourself: > > puts "\\".gsub("\\", "\\\\") > > Why is that so? Well, it's an faq. In short: The backslash is special in strings *and* in the replacement text. So for every literal backslash you need four backslashes, which is quite unreadable. If you don't need \1 and Co you better use the block form: gsub("\\") { "\\\\" }. mfg, simon .... hth