- or download this
my $s = "ZBBBCZZ";
my @x;
push @x, $1 while $s =~ /((.)\2*)/g;
- or download this
s = "ZBBBCZZ"
x = []
s.scan(/((.)\2*)/){x.push [$~[0]]}
- or download this
import itertools
s = "ZBBBCCZZ"
x = [''.join(g) for k, g in itertools.groupby(s)]
- or download this
group "ZBBBCCZZ"