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

Re^3: Seeking clarification on possible bug in regex using \G and /gc

by choroba (Cardinal)
on Mar 14, 2018 at 23:52 UTC ( [id://1210925]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Seeking clarification on possible bug in regex using \G and /gc
in thread Seeking clarification on possible bug in regex using \G and /gc

> Should instead print

Why? Using perl -Mre=debug will show you your mistake:

... Matching REx "\G \z" against "" 3 <foo> <> | 1:GPOS(2) 3 <foo> <> | 2:EOS(3) 3 <foo> <> | 3:END(0) Match possible, but length=0 is smaller than requested=1, failing! Match failed

The length=1 request comes from the previously mentioned Repeated Patterns Matching a Zero-length Substring:

The higher-level loops preserve an additional state between iterations: whether the last match was zero-length. To break the loop, the following match after a zero-length match is prohibited to have a length of zero.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found