$s = "xxyyyyyy"; $s =~ m/((x+)(??{'y' x length($2)}))/ and print "$1\n";