in reply to Extracting a substring according to some criteria

IIUC your question, which I'm not completely sure about, and taking into account Skeeve's comment, I'm giving you a (hopefully correct) hint/incomplete solution:
my $allow=join '|', qw/AA AG GC GT CA CG TT TC/; my $disallow=join '|', qw/AC AT GG GA CC CT TG TA/; # ... my @chunks=/(?:$allow).*?(?=$disallow)/g;