in reply to substring selection from a string on certain qualifying conditions

A few more examples would be good, but this produces the desired output for the two you given:

C:\test>876075 AGRTGAXWXX : [ AGRTGA ] ACRMGAHKMAHGTXX : [ GAHKMAHGT, ACRMGAHKMA ]
#! perl -slw use strict; use Data::Dump qw[ pp ]; sub maxMatches { my $s = shift; my %uniq; LOOP: for my $o ( 0 .. length( $s ) - 10 ) { my( $match ) = $s =~ m[.{$o}([ACGT].{0,8}[ACGT])]; m[$match] and next LOOP for keys %uniq; $uniq{ $match }++; } return keys %uniq; } while( <DATA> ) { chomp; printf "$_ : [ %s ]\n", join ', ', maxMatches( $_ ); } __DATA__ AGRTGAXWXX ACRMGAHKMAHGTXX

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.