in reply to Re: Regex KungFu help needed
in thread Regex KungFu help needed
You can put the whole term in the look-ahead to make things a bit simpler and you could take advantage of the $scalar = () = $string =~ m{$pattern}g; idiom rather than successive incrementing, wrapping the whole thing in a map.
$ perl -Mstrict -wle ' > my $seq = q{GGGGGGGAGAAAAAAAAAAAAAAAGAAGGA}; > my @pats = qw{ AAAAA GGGGG GGAGA GAAGG }; > my @cts = map { > my $re = qr{(?=\Q$_\E)}; > my $ct = () = $seq =~ m{$re}g; > } @pats; > print qq{@cts};' 11 3 1 1 $
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex KungFu help needed
by AnomalousMonk (Archbishop) on Oct 02, 2009 at 22:59 UTC | |
by johngg (Canon) on Oct 03, 2009 at 11:03 UTC | |
by grizzley (Chaplain) on Oct 05, 2009 at 07:17 UTC |