Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Regex: matching character which happens exactly once (using global memory)

by QM (Parson)
on Oct 23, 2017 at 14:46 UTC ( [id://1201900]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Regex: matching character which happens exactly once (using global memory)
in thread Regex: matching character which happens exactly once

I didn't expect my forward ref to work, if that's what you thought. The regex engine would have to include a flag to indicate when the first capturing parens were seen, and do the right thing.

-QM
--
Quantum Mechanics: The dreams stuff is made of

  • Comment on Re^3: Regex: matching character which happens exactly once (using global memory)

Replies are listed 'Best First'.
Re^4: Regex: matching character which happens exactly once (updated)
by LanX (Saint) on Oct 23, 2017 at 14:50 UTC
    What is the right thing???

    I can only judge the implementation, which considers $1 ff to be global.

    update

    This demonstrates whats happening, $2 is always the next character or empty.

    DB<322> ;m/ ^ .*? (?{say "<$_ $2>"}) (.) (?=(.|$)) (*FAIL)/x <babab > <babab a> <babab b> <babab a> <babab b> <babab >

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      You're asking theoretical questions, and then getting bogged down in current implementation.

      Turn this around. What would you want to happen if you had a forward reference?

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

        You seem to think it's a bug, for me it's most likely a feature.

        I think this stems from the foundations of regular expressions as state machines.

        > What would you want to happen if you had a forward reference?

        Something wonderful, HAL!

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-25 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found