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を作成しようとしています:
'09/02 10:00 hs 任意の文字列'
次のようなものを返します:
'09/02 10:00'
したがって、私の gsub は数字以外のすべての文字列を削除する必要がありますが、「:」と「/」を維持する必要があります
助けてください。
数字以外のすべての文字列を取り出しますが、「:」と「/」が必要です
"09/02 10:00 hs any string".gsub(/[^0-9\/:]/, '') # "09/0210:00"