开发者

How can I output a forward slash preceded by a back slash in ruby?

开发者 https://www.devze.com 2023-02-11 00:27 出处:网络
Is there a way to output a for开发者_JS百科ward slash preceded by a back slash in ruby? for example: a\\/b

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消