If I have a string such as \"aabbbbccffffdeffffgg\" and I wanted to split the string into this array: [\"aa\", \"bbbb\", \"cc\", \"ffffd\", \"e\", \"ffff\", \
\"aabbbbccffffdeffffgg\"
[\"aa\", \"bbbb\", \"cc\", \"ffffd\", \"e\", \"ffff\", \
Here is a non-regexp version
str = "aabbbbccffffdeffffgg" p str.chars.chunk(&:itself).map{|x|x.last.join} #=> ["aa", "bbbb", "cc", "ffffd", "e", "ffff", "gg"]