http://www.perlmonks.org?node_id=638193


in reply to Re: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
in thread Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)

Ruby solution
x = [] "ZBBBCZZ".scan(/((.)\2*)/){ x << [$~[0]]; x.flatten!}
.flatten is needed else you get
# => [["Z"], ["BBB"], ["C"], ["ZZ"]]
as result.

But this is quite an ugly solution anyway... in fact, perl looks almost as readable in this example ;)

not sure how to solve this any easier though, hmm i wonder if .each could be used and then another grouping way... I really dont like the regex magic of the ruby solution, cant you guys think of another solution :-)