$ perl -wle'print $1 while "aabbaab" =~ /((.)\2+)/sg;' aa bb aa