in reply to self limiting regex help

If your string is allowed to be empty, try this:
print "match" if $string =~ /[atcg]*([RYMKSWHBVDN][atcg]*){0,2}/i;
If not, try this:
print "match" if $string and $string =~ /[atcg]*([RYMKSWHBVDN][atcg]*) +{0,2}/i;
(Warning, neither was tested)

Update:Sorry about that: You're both right, I misunderstood the initial request. The regex above matches up to 2 occurrances of any of the alternate codes, not any number of occurrances of up to 2 of the alternate codes.

You could do what you want with an extremely long regex which enumerates every combination of 2 alternate codes. That's a really bad answer, though: it would be much shorter and more straightforward to do it with regexes supplemented by other perl code.

Sorry for the wrong answer :)