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]/).joinline.gsub(/\D/, '')
Try each on you console.
Also check the benchmark report in that post.