What surprised me was the magnitude of the performance degradation here, compared to other code doing a similar number of matches on the exact same output (the multi-line approach I briefly mention at the bottom of my post). JavaFan explained why that is the case.
Comment on Re^2: Impact of special variables on regex match performance