in reply to substrings that consist of repeating characters
While I wouldn't recommend it, I didn't see the following approach:
my $string = 'AAATTTAGTTCTTAAGGCTGACATCGGTTTACGTCAGCGTTACCCCCCAAGTTATT +GGGGACTTT'; my %max; $string =~ s[(.)\1*][if ( length($&) > ($max{$1} // 0) ) {$max{$1} = l +ength($&); }]eg; for my $k (sort keys %max) { print"$max{$k} ", $k x $max{$k}, "\n"; }
output
3 AAA 6 CCCCCC 4 GGGG 3 TTT
|
|---|