This solution is functionally identical to the one I called a pure regex solution that works
, so it's purely a matter of taste which you consider "THE solution".
In both cases, they do try to make the match as long (up to six chars) as possible, though given GYNNNGYYY, you would get GYNN and NGYY rather than GYN and NNGYY. Earlier matches take all they can.
Matching residues makes it very tricky. I will have to ponder that. Meanwhile, you might find it useful to find all your non-residue matches, and then use String::Approx to find copies of those with residues.
Caution: Contents may have been coded under pressure.