繁体   English   中英

从字符串中删除“ \\”

[英]Removing ' \ ' from a string

我需要从字符串中出现在红宝石上的字符串中删除“ \\”。 是否可以使用gsub或类似的东西?

例如,考虑一个字符串,字符串=“嘿老板\\您好吗”。 我需要将其打印为“嘿老板,你好吗”。

如何使用:

'hey boss\ how are you'.gsub('\\',' ')     

=> "hey boss how are you" 
'hey boss\ how are you'.tr('\\','')
'hey boss\ how are you'.delete!('\\')
   => "hey boss how are you"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM