Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Capture Lookahead

by Roy Johnson (Monsignor)
on Jul 26, 2005 at 02:27 UTC ( #478054=note: print w/ replies, xml ) Need Help??


in reply to Capture Lookahead

Putting the capturing parens outside the lookahead captures only the characters actually consumed. Putting them inside the lookahead will capture what the lookahead would have consumed (had it not been zero-width). So you'd have to do something like
while ($str =~ /(?=(..{$len}))./g) { print pos, "$1\n"; }
That reads the whole desired capture as a lookahead, then consumes the one char.

Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2016-08-28 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (392 votes). Check out past polls.