Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Keep It Simple, Stupid
 
PerlMonks  

Re^2: counting overlapping patterns

by ikegami (Patriarch)
on Feb 18, 2005 at 16:46 UTC ( [id://432532]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: counting overlapping patterns
in thread counting overlapping patterns

Alternatively,

while ('AAAA' =~ /A(?=A)/g) { $count++; }

which looks slightly less weird to me.

Replies are listed 'Best First'.
Re^3: counting overlapping patterns
by Eimi Metamorphoumai (Deacon) on Feb 18, 2005 at 17:15 UTC
    But requires rewriting the pattern. Mine will work even if the pattern comes from a variable, or contains different possibilities for the first character ('/AA|BB/' becomes '/(?=AA|BB)/'). My approach was to try to do minimal tinkering with the original, but yeah, it's not as obvious what's actually going on.
      Good point.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://432532]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.