Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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.


Comment on Re: Capture Lookahead
Download Code

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 musing on the Monastery: (8)
As of 2014-09-19 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (135 votes), past polls