in reply to positions of multiple matches
The 'magic' is in the (?{ ... }) construct. This allows you to insert perl into your regexen.use re 'eval'; my $seq = 'xxxTATAATGyyyTatAtAtzzz'; my $box = qr{ (?i) TATA [TA] [TA] [TAG] }xms; ;; my @TATAs; my @matches = $seq =~ m{ ($box) (?{ push @TATAs,[$+,pos() - length $+] }) }msxg; print "matched '$_->[0]' at pos $_->[1]\n" for @TATAs;
|
---|