From: Pradeep Elankumaran Date: 2007-11-07T10:28:22+09:00 Subject: Re: Escaping characters In Ruby, there is a distinction between strings that are between double quotes and strings in single quotes. "\\" escapes the necessary characters, and also allows substitution. ex: "#{name}" => "Pradeep" '\\' does not do any of these. ex: '#{name}' => '#{name}' Single-quoted strings are faster than double-quoted strings. - Pradeep On Nov 6, 2007, at 8:00 PM, Jeremy Woertink wrote: > I don't understand this. > > > irb(main):002:0> '\'' > => "'" > irb(main):003:0> '\\' > => "\\" > irb(main):004:0> > > > I know the backslash escapes a character, so in the first line, I > escape > the quote so it will return a string that is a single quote, but in > the > second one I would expect it to return "\", instead it returns "\\" > both > backslashes, and I only want one of them. My actual problem looks like > this: > > irb(main):004:0> "(G\\D01=Name~\D02=1234~\\" > => "(G\\D01=Name~D02=1234~\\" > > The string that is returned is wrong,but if I do > irb(main):005:0> "(G\\D01=Name~\\D02=1234~\\" > => "(G\\D01=Name~\\D02=1234~\\" > > the string that is returned is still wrong. > > > ~Jeremy > -- > Posted via http://www.ruby-forum.com/. >