harangzsolt33 has asked for the wisdom of the Perl Monks concerning the following question:
Sample string: "AB ABDA DCACCB AAA BSAA CAAB ACS ABA DBA BA DASSABACA +A" I'm looking for either: BA[ABC]{2} OR CA[CD]{2} OR DA[SC]{2} So, I would write: /BA[ABC]{2}|CA[CD]{2}|DA[SC]{2}/
Is there a way to get a return value of 1, 2, or 3 depending on which pattern was matched first? How would I do that?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex question - identify which pattern comes first
by ikegami (Patriarch) on May 02, 2026 at 01:53 UTC | |
by harangzsolt33 (Deacon) on May 02, 2026 at 02:15 UTC | |
by LanX (Saint) on May 02, 2026 at 13:28 UTC |