in reply to Re^4: Applying regexes to streams: Perl enhancement idea (bug+fix)
in thread Applying regexes to streams: Perl enhancement idea

But how does the regex engine know that that search sans /z is supposed to be the finishing search of the previous series of /z searches, as opposed to an entirely new pattern to be applied? What I'm talking about is analogous to using /gc and then finally only /c to conclude the series of matches. If there was no /g, the (lack of) presence of /c alone would be ambiguous.

Makeshifts last the longest.

  • Comment on Re^5: Applying regexes to streams: Perl enhancement idea

Replies are listed 'Best First'.
Re^6: Applying regexes to streams: Perl enhancement idea
by tye (Sage) on Jan 13, 2003 at 00:39 UTC

    Because

    We already have a separate "continue where it left off last time" feature for regular expressions: //g in a scalar context and pos().
    and that is what we'd use. //z would not imply "start where you left off last time". There is no reason for it to because we already have //g and pos(). Why do you think I've been using //g and messing with pos() in my example?

    //z would only tell the regex engine to fail [and set pos()] if it looks at the end of the string/buffer. It wouldn't tell it to start where it left off and it wouldn't keep track of where it left off other than by setting pos().

                    - tye