Strings • Exercise 5/6

Extract Numbers

00:00
0
20 points

Instructions

Create a function extract_numbers that takes a string and returns
an array of all integers found in that string.

Use Ruby's scan method with a regular expression:
ruby
"abc".scan(/pattern/) # Returns array of matches

The regex \d+ matches one or more digits.

Example:
```ruby
extract_numbers("I have 3 cats and 2 dogs")

=> [3, 2]

Your Code

Results

Click "Run Tests" to see results