Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Return value from positive look behind (updated)

by AnomalousMonk (Archbishop)
on Nov 11, 2020 at 23:12 UTC ( [id://11123599]=note: print w/replies, xml ) Need Help??


in reply to Return value from positive look behind

Another example of the effect of what you were doing in the OP (i.e., a non-zero-width capture within a zero-width assertion):

Win8 Strawberry 5.8.9.5 (32) Wed 11/11/2020 18:02:18 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings -l my $s = 'ABCDE'; while ($s =~ m{ (?= (\w+)) }xmsg) { print $1; }; ^Z ABCDE BCDE CDE DE E
A useful trick when you want overlapping captures.

Update: This might be a better example of overlapping capture:

Win8 Strawberry 5.8.9.5 (32) Wed 11/11/2020 21:41:12 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings -l my $s = 'ABCDE X YZ FGHI'; while ($s =~ m{ (?= (\w{3})) }xmsg) { print "'$1'"; }; ^Z 'ABC' 'BCD' 'CDE' 'FGH' 'GHI'


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-19 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found