in reply to match all instances?

Your index function always starts from the beginning of the string, so at best has only two distinct values.

You probably want the pos function and a while loop. Collecting an array of K's and R's is not getting you much. I'm going to rewrite the regex as a character class, though there's nothing wrong with yours.

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

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: match all instances?
by Anonymous Monk on May 27, 2006 at 16:08 UTC
    Thank you very much!!! Problem solved