How can I output a forward slash preceded by a back slash in ruby?
Is there a way to output a for开发者_JS百科ward slash preceded by a back slash in ruby?
for example: a\/b
"a\/b"
yields a\b
"a\\/b"
yields a\\/b
irb(main):001:0> puts 'a\/b'
a\/b
=> nil
irb(main):002:0> puts "a\\/b"
a\/b
=> nil
I get a\/b
when I output "a\\/b"
. The single-quotes method should work as well, however.
精彩评论