如何使用 gsub 替换 “&” (仅有的)
我有这个字符串“tv&media”,我想做的就是删除“&”象征。
请您解释一下我是如何做到这一点的,因为我已经尝试过,但我真的不知道需要做什么。
I have this string "tv&media" and all I want to do is remove the "&" symbol.
Please can you explain how I do this as I've tried but I don't really know what needs to be done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
到目前为止你实际上尝试过什么?
这实际上只是
查看 gsub 上的 rubydoc了解更多详情。
注意:
.gsub
返回一个新字符串,并保持原始字符串不变。如果想改变原来的字符串,需要.gsub!
What have you actually tried so far?
It's really just
Check out the rubydoc on gsub for more details.
Note:
.gsub
returns a new string and leaves the original string untouched. If you want to change the original string, you need.gsub!