比如:ABBABA出现的位置向量是(1,4)AB出现的位置是(1,4)ABB出现的位置是(1)
my $s='ABBAB';
my $l=length $s;my $off=0;my $substr = 'BB';
for my $i(0..$l-1){my $p = index $s, $substr, $off;if($p<0){last;}$off = $p+1;print "$off $p\n";}