Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Refer by relative way to regex group (eg. the last one)

by RMGir (Prior)
on Jan 19, 2022 at 14:28 UTC ( #11140608=note: print w/replies, xml ) Need Help??


in reply to Re: Refer by relative way to regex group (eg. the last one)
in thread Refer by relative way to regex group (eg. the last one)

The \g{-1} syntax is interesting, I don't recall that one. When did it come about? (Of course, it's possible it's been around since Perl 4 and I just missed it :) )

Mike
  • Comment on Re^2: Refer by relative way to regex group (eg. the last one)

Replies are listed 'Best First'.
Re^3: Refer by relative way to regex group (eg. the last one)
by Fletch (Bishop) on Jan 19, 2022 at 14:41 UTC

    Looks like 5.10 according to perl5100delta:

    Relative backreferences A new syntax "\g{N}" or "\gN" where "N" is a decimal integer a +llows a safer form of back-reference notation as well as allowing re +lative backreferences. This should make it easier to generate and emb +ed patterns that contain backreferences. See "Capture buffers" in perlre. (Yves Orton)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re^3: Refer by relative way to regex group (eg. the last one)
by Corion (Patriarch) on Jan 19, 2022 at 14:40 UTC

    Grepping the perldelta* files for \\g lists perl5100delta, so likely the feature was introduced with Perl 5.10.0.

Re^3: Refer by relative way to regex group (eg. the last one)
by choroba (Archbishop) on Jan 19, 2022 at 14:44 UTC
    Syntax::Construct to the rescue :-)

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^3: Refer by relative way to regex group (eg. the last one)
by LanX (Sage) on Jan 19, 2022 at 14:35 UTC
Re^3: Refer by relative way to regex group (eg. the last one)
by Anonymous Monk on Jan 19, 2022 at 16:00 UTC

    Perl 5.9.5 if you want to be picky.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140608]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2022-05-26 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (93 votes). Check out past polls.

    Notices?