Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: frame shift in Perl string matching

by GrandFather (Sage)
on Oct 09, 2012 at 04:55 UTC ( #997922=note: print w/replies, xml ) Need Help??


in reply to frame shift in Perl string matching

Use a look ahead assertion:

my $str = "PPPP"; my $search = "PP"; my $count = () = $str =~ /(?=$search)/g; print $count;
True laziness is hard work

Replies are listed 'Best First'.
Re^2: frame shift in Perl string matching
by GTI (Initiate) on Oct 09, 2012 at 05:12 UTC

    Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997922]
help
Chatterbox?
[LanX]: Station Palace
[Eily]: yay well the one in Nancy is ... hu, a station?
[LanX]: no wonder he prefers to walk ..

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2017-12-13 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (369 votes). Check out past polls.

    Notices?