From: Todd Benson Date: 2007-11-07T10:41:27+09:00 Subject: Re: Escaping characters On 11/6/07, 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. s = '\\' puts '\\' #returns \ s.length #returns 1 It's one byte of value 134 in base 10. What you are seeing is the representation of it in irb. Like try... s = "hello " Note the return character before the second end quote. Todd