in reply to Update to smartmatch

I use smartmatch to check a string against a list of precompiled regexen. I need to see if ANY of the regexen matches. If one does (I don't care which), then I do something with the capture group on the next line. That part is always the same - I just don't know which regex (if any) is going to match the input string. I don't know how to match a string against ANY regex in a list of them without smartmatch without using a loop construct with flow control. The difference is so big that I go out in public with `no warnings 'experimental::smartmatch'` at the top of my code just for this one use case.

Replies are listed 'Best First'.
Re^2: Update to smartmatch
by choroba (Cardinal) on Feb 18, 2018 at 11:42 UTC
    Just join the regexes into one large regex. Use | to separate them, and use branch reset (?|...) to start counting the capture groups from 1 in each alternative.
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,