If you want to count overlapping matches, a plain regular expression as you wrote it isn't the easiest way to approach the problem.
Personally, I would simply iterate over the string either for each character or by resetting pos and using \G as documented in perlre:
use strict; my $line= 'AAALVDENEC'; while( $line =~ /\G.*?(AA|AL|DA|DE|DV|VD|DW|QD|SD|HD|ED|DY|VE|EN|EI|KE +|NV|VP|FV|SS|WK|KK)/igc ) { print sprintf 'Matched [%s] at %d', $1, pos($line); pos( $line )--; }
In reply to Re^3: how do i count the 22 selected di-peptides from a multifasta file separately for each sequence
by Corion
in thread how do i count the 22 selected di-peptides from a multifasta file separately for each sequence
by SOMEN
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |