my $string = 'aaabbcddeef'; while($string =~ m/((.)\2*)/gi) { print "$1\n"; } __OUTPUT__ aaa bb c dd ee f