while( $string =~ m/((\w)\2($!\2)\w)/g ) { print $1, "\n"; } =pod matching: ABCDEEFGHIJJJKLMNOOOOPQRSTUVWXXYZ JJJK OOOO =cut