Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regex question - identify which pattern comes first

by tybalt89 (Monsignor)
on May 05, 2026 at 17:20 UTC ( [id://11167700]=note: print w/replies, xml ) Need Help??


in reply to Regex question - identify which pattern comes first

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11167676 use warnings; local $_ = 'AB ABDA DCACCB AAA BSAA CAAB ACS ABA DBA BA DASSABACA A'; my $first = /(BA[ABC]{2})|(CA[CD]{2})|DA[SC]{2}/ ? $1 ? 1 : $2 ? 2 : 3 + : 0; print "first is $first\n";

Outputs:

first is 2

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2026-05-12 15:56 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.