How to match all occurrences of a regular expression in Ruby November 24, 2022 by Tarik Using scan should do the trick: string.scan(/regex/)