in reply to Pattern match location finding
NOTE that I'm sure that diotalevi's solution is much more efficient than mine. But this one I can understand simply, and that one I have to sit and think about ;-)my $mystring = "AABAABBBB"; my @myarray = split //, $mystring; my $ct = 0; foreach my $element (@myarray) { if ($element eq "B") { push(@myoccurrences, $ct); } $ct++; }
HTH.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Pattern match location finding
by pzbagel (Chaplain) on Feb 18, 2004 at 20:50 UTC | |
by feloniousMonk (Pilgrim) on Feb 18, 2004 at 21:06 UTC |