簡體   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