From: james.d.masters@... Date: 2007-06-07T07:35:06+09:00 Subject: Re: Error when substituting a backslash in a string On Jun 6, 2:59 pm, "Federico Zagarzaz�" wrote: > Why can't I substitute a single backslash in a string? > a = "\\6" > ... > p a.sub('\', '') Because you're essentially escaping a single quote in your String#sub method call. Double escape that too: irb(main):001:0> a = "\\6" => "\\6" irb(main):002:0> a.sub('\\', '') => "6" Why is this? Suppose I wanted to make a string with single quotes in it: irb(main):003:0> a = '\'hello\'' => "'hello'"