Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: counting overlapping patternsby merlyn (Sage) |
on Feb 18, 2005 at 23:33 UTC ( [id://432570]=note: print w/replies, xml ) | Need Help?? |
Here's a bizarre way of doing it, taking a hint from my Prolog studies (thanks Ovid!):
Essentially, match successfully, count it, but then fail the match (an empty string can always match, so negating that always fails). -- Randal L. Schwartz, Perl hacker
In Section
Seekers of Perl Wisdom
|
|