Mega Code Archive

 
Categories / Ruby / String
 

Extract numbers from a string

"The car costs $1000 and the cat costs $10".scan(/\d+/) do |x|   puts x end