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.
の文字列があり'30.04/2012'、出力が になるように分割したい['30', '04', '2012']。それは本質的にx.split('.') and x.split('/')です。これを効率的に行うにはどうすればよいですか?
'30.04/2012'
['30', '04', '2012']
x.split('.') and x.split('/')
代替で正規表現を使用します。
x.split(/[.\/]/)
x = "30.04/2012" x.scan /\d+/ # => ["30", "04", "2012"]