In ruby, I am trying to convert
'\"\"'
to
'""'
In short, what's the cleanest way to remove the backslashes?
您可以在任何字符串上使用gsub
方法来删除不需要的字符。
some_string.gsub('\\"', '"')
完后还有:
'\"\"'.delete("\\") # => "\"\""
Use String#tr
s = '\"\"'
s.tr('\\', '') # => "\"\""
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.