$ perl -e 'print $&,"\n" while ( "aabbaab" =~ /(.)\1/g )' aa bb aa