Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: counting overlapping patterns

by dave_the_m (Monsignor)
on Feb 18, 2005 at 20:28 UTC ( #432501=note: print w/replies, xml ) Need Help??


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

$count++ while $string =~ /\GAA/gc;
Er, no, the \G there serves no purpose as that's the default behaviour anyway. On this other hand this will work, by only consuming the first character of the match:
$count++ while $string =~ /A(?=A)/g;

Dave.

Replies are listed 'Best First'.
Re^3: counting overlapping patterns
by Anonymous Monk on Feb 18, 2005 at 20:34 UTC
    Dave you truly are "the m". That works as promised. Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://432501]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2019-11-12 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (66 votes). Check out past polls.

    Notices?