Extract number from string in Ruby
There are many Ruby ways as per http://www.ruby-forum.com/topic/125709
line.scan(/\d/).join('')
line.gsub(/[^0-9]/, '')
line.gsub(/[^\d]/, '')
line.tr("^0-9", '')
line.delete("^0-9")
line.split(/[^\d]/).join
line.gsub(/\D/, '')
Try each on you console.
Also check the benchmark report in that post.
there is even simpler solution
line.scan(/\d+/).first