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

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!

  • Comment on Re^4: Regex: matching character which happens exactly once (updated)
  • Download Code

Replies are listed 'Best First'.
Re^5: Regex: matching character which happens exactly once (updated)
by QM (Parson) on Oct 23, 2017 at 16:57 UTC
    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!