in reply to Regex question - identify which pattern comes first
if ( /(BA[ABC]{2})|(CA[CD]{2})|(DA[SC]{2})/ ) { my $first = ( defined( $1 ) ? 1 : defined( $2 ) ? 2 : 3 ); ... }
local our $first; / (?: BA[ABC]{2} (?{ $first = 1; }) | CA[CD]{2} (?{ $first = 2; }) | DA[SC]{2} (?{ $first = 3; }) /x;
Update: I had mixed up (??{ }) and (?{ }). Fixed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex question - identify which pattern comes first
by harangzsolt33 (Deacon) on May 02, 2026 at 02:15 UTC | |
by LanX (Saint) on May 02, 2026 at 13:28 UTC | |
by harangzsolt33 (Deacon) on May 02, 2026 at 14:20 UTC | |
by LanX (Saint) on May 02, 2026 at 14:43 UTC |