c:\@Work\Perl>perl -wMstrict -le "my $s = 'XXXxxxTGAxxTGAxxxxxxx'; while ($s =~ m{ (?{ print qq{trying a match at offset }, pos $s }) (?: \w\w\w)*? (TGA) }xmsg) { print qq{matched TGA beginning at offset $-[1]}; } " trying a match at offset 0 matched TGA beginning at offset 6 trying a match at offset 9 trying a match at offset 10 trying a match at offset 11 matched TGA beginning at offset 11 #### c:\@Work\Perl>perl -wMstrict -le "my $s = 'XXXxxxTGAxxTGAxxxxxxx'; while ($s =~ m{ \G (?{ print qq{trying a match at offset }, pos $s }) (?: \w\w\w)*? (TGA) }xmsg) { print qq{matched TGA beginning at offset $-[1]}; } " trying a match at offset 0 matched TGA beginning at offset 6 trying a match at offset 9 #### my $s = 'XXXxxxTGAxxTGAxxxxxxx'; while ($s =~ m{ (?{ print qq{trying a match at offset }, pos $s }) (?: \w\w\w)*? (TGA) }xmsg) { print qq{matched TGA beginning at offset $-[1]}; } #### c:\@Work\Perl>perl -wMstrict -le "my $s = 'XXXxxxTGAxxTGAxxxxTGAxx'; while ($s =~ m{ (?{ print qq{trying a match at offset }, pos $s }) (?: \w\w\w)*? (TGA) }xmsg) { print qq{matched TGA beginning at offset $-[1]}; } " trying a match at offset 0 matched TGA beginning at offset 6 trying a match at offset 9 matched TGA beginning at offset 18