I thought the documentation said that:
...
which prints
Got a TGA stop codon at position 18
Got a TGA stop codon at position 23
Position 18 is good, but position 23 is bogus. What happened?
The answer is that our regexp works well until we get past the last real match. Then the regexp will fail to match a synchronized TGA and start stepping ahead one character position at a time, not what we want. The solution is to use \G to anchor the match to the codon alignment:
...
If there is no match at all, I would assume that we are always past the last real match.