Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Regex question - identify which pattern comes first (named captures)

by ikegami (Patriarch)
on May 03, 2026 at 15:53 UTC ( [id://11167691]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex question - identify which pattern comes first (named captures)
in thread Regex question - identify which pattern comes first

Adjusted for OP:

if ( $str =~ / (?: (?<_1> BA[ABC]{2} ) | (?<_2> CA[CD]{2} ) | (?<_3> DA[SC]{2} ) ) /x ) { my $first = substr( ( keys( %+ ) )[0], 1 ); ... }

Update: Added missing ), as LanX pointed out.

Replies are listed 'Best First'.
Re^3: Regex question - identify which pattern comes first (named captures)
by LanX (Saint) on May 03, 2026 at 21:29 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2026-05-12 15:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.