Another trick is you can put some regex engines in right-to-left mode, so my lazy (and admittedly relatively expensive cpu-wise) solution was to match ltr for first and rtl for last.
Re:Advent of Code 2023 is nigh
by dumbo-octopus on Friday December 01, 2023 @04:59PM
(#38493071)
Or just tack a greedy anything-matcher to the front of the regex: .*(?: ... )
[0] https://www.regular-expressions.info/lookaround.html