'bbbaaabaaaa'.match(/(\w)(\1+)/g) // Output: ['bbb', 'aaa', 'aaaa']
(\w): Match any alphanumeric character and store this in a capture group (think a temporary variable).
(\1+): match one or more characters that are the same as what was captured in the first capture group.
This example is written using
'bbbaaabaaaa'.scan(/(\w)(\1+)/).map(&:join) # Output: ['bbb', 'aaa', 'aaaa']