Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Code expressions in regex refer to the regex group captured, by name / relative

by haukex (Archbishop)
on Jan 14, 2022 at 01:49 UTC ( [id://11140443]=note: print w/replies, xml ) Need Help??


in reply to Code expressions in regex refer to the regex group captured, by name / relative

See %+ and %-; the following prints "oo":

use warnings; use strict; 'foo' =~ /(?'name'(?=o)(\w+))(?{print $+{name}})/;

But also note the documentation of (?{...}):

WARNING: Using this feature safely requires that you understand its limitations. Code executed that has side effects may not perform identically from version to version due to the effect of future optimisations in the regex engine. For more information on this, see Embedded Code Execution Frequency.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found