Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by QM (Parson)
on Oct 23, 2017 at 14:46 UTC ( #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 (Cardinal) 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
Node Status?
node history
Node Type: note [id://1201900]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2021-04-23 08:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?