From: Austin Ziegler Date: 2005-09-29T23:08:49+09:00 Subject: Re: Backslashes On 9/29/05, Han Holl wrote: > Hi, > > Why does > '\\'.gsub('\\','\\\\').size > produce 1 ? > > Is this a bug, or should it be specially documented ? It's not a bug, and it's relatively well known. I recommend: '\\'.gsub(/\\/) { "\\\\" }.size The *trick* is that strings consider \ special, so to use special regexp values (like \1), you need \\1. So to get \\, you actually need \\\\\\\\ (yes, eight of them). The first round of interpolation (string) will result in \\\\; the second round of interpolation (regexp substitution values) will result in \\. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca