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"