in reply to Re^2: Regular Expressions
in thread Regular Expressions

I understand that ^ here is "from the begining of the sting".
I didn`t know, that each match would overwrite capture group. Thanks. :)
I can`t find something about overwiting capture group in perlretut (am I a bad finder?). Are there any docs about it?
Thanks. :)

Nick <znick at inbox dot ru>

Replies are listed 'Best First'.
Re^4: Regular Expressions
by Roy Johnson (Monsignor) on May 17, 2005 at 21:50 UTC
    I don't think it's documented. It's just a case of having one place to store a capture and capturing into it multiple times. Each time a capture happens, the old value is overwritten. I wish it were documented, though.

    Caution: Contents may have been coded under pressure.
      It is documented. perldoc perlre
          The numbered match variables ($1, $2, $3, etc.) and the related
          punctuation set ($+, $&, $`, $', and $^N) are all dynamically scoped
          until the end of the enclosing block or until the next successful match,
          whichever comes first. (See "Compound Statements" in perlsyn.)
        I read "the next successful match" as a separate Perl operation, not the internal iteration involved in matching ()*. There is, technically, nothing that dictates the order of internal matching, and if the overall match fails, $1 is not set to the last iteration of ()* that did match.

        Caution: Contents may have been coded under pressure.