my $string = 'LPNTGVTNNAYMPLLGIIGLVTSFSLLGLXKARRD'; while ($string =~ /([KR])/g) { print pos($string) - length($1), $/; } __END__ 30 32 33