On Nov 6, 7:00 pm, Jeremy Woertink <jeremywoert... / gmail.com> 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 viahttp://www.ruby-forum.com/.

If you actually output the string:

> puts '\\'
\
=> nil

you should get the result you're expecting.