News for hackers. Stuff that matters.
Re:Advent of Code 2023 is nigh by torbencarstens on Friday December 01, 2023 @12:10PM (#38489214)
Another option when using regex would be to use the lookahead[0] operator (as long as supported, which is the case for the python re module)

  (?=(one|two|three|[...]))
would return `["two", "one"]` for the input string `twone` since the lookahead operator doesn't consume the next character.

[0] https://www.regular-expressions.info/lookaround.html

Re:Advent of Code 2023 is nigh by Huppie on Friday December 01, 2023 @02:11PM (#38490862)
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: .*(?: ... )