in reply to Re: \g{-2} for inside (?{ ... })
in thread \g{-2} for inside (?{ ... })

Thanks. That's the only documented approach I've found that doesn't rely on counting captures, but it makes for mighty long patterns and mighty long names.

Replies are listed 'Best First'.
Re^3: \g{-2} for inside (?{ ... }) (repeat)
by tye (Sage) on Nov 07, 2008 at 02:39 UTC
    and mighty long names

    Can't you just use 'x' and 'y' over and over? Doesn't %+ give you the most-recently matched instance matching the given name?

    - tye        

      Indeed! I misunderstood the documentation.

      use 5.010; # re features use strict; use warnings; for ('abcdef') { m{ (?(DEFINE) (?<x> (?<i1> . ) (?<i2> . ) (?{ '...' }) ) (?<y> (?<i1> . ) (?<i2> . ) (?{ print("($+{i1},$+{i2})") }) ) (?<z> (?<i1> . ) (?<i2> . ) (?{ '...' }) ) ) (?&y)+ }x; } print("\n");