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