Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前有一个字符串可以从字符串中删除空格,但是我现在也需要从字符串中删除正斜杠。我对正则表达式不是很好,可以使用一些帮助谢谢。这是我拥有的当前正则表达式:gsub(/\s+/, "")如何修改它以删除 / ?我在控制台中玩过,似乎无法理解。
gsub(/\s+/, "")
您必须转义正斜杠,因为它是一个特殊字符。像这样的东西:
s = "This is a line / string" s.gsub(/[\s\/]/, '') # => "Thisisalinestring"