I used regexes in a similar way but my implementation was vibecoded, hmmm, using your analysis Claude Code writes code by hand.