http://qs1969.pair.com?node_id=11129283


in reply to Re^4: How to enforce match priority irrespective of string position
in thread How to enforce match priority irrespective of string position

I guess OP might try use his '(.*?)' within every branch to achieve priority matches. But as he wants to capture it, he will use more capturing groups, e.g. 1+2, 3+4 and 4+5, where $1, $3 and $5 is what '(.*?)' capture. Or he may use '(?|...)' group for parallel numbering (https://perldoc.perl.org/perlre#(?%7Cpattern).