How to match all occurrences of a regular expression in Ruby

Using scan should do the trick:

string.scan(/regex/)

Leave a Comment