Please, if you write regexes like these, comment them...
A great way to do it is to split them up by concatenating them across a bunch of lines, and put a brief explanation at the end of each non-obvious part (to the right, on the same line).
Plus that also lets you indent within nested parentheses, making it that much more understandable.
I'm baffled when I come across a file like this where the code itself is heavily commented, but a gnarly regex is not. Regexes are not strings, they are code -- and with their syntax, they need comments even more.
First, I don't want to waste time feeding something into an LLM that should be commented in the first place.
Second, not at all. An LLM can tell you how the regex works (hopefully). It can't tell you what each piece means in terms of the program's logic. Or at least not always and not reliably.
A great way to do it is to split them up by concatenating them across a bunch of lines, and put a brief explanation at the end of each non-obvious part (to the right, on the same line).
Plus that also lets you indent within nested parentheses, making it that much more understandable.
I'm baffled when I come across a file like this where the code itself is heavily commented, but a gnarly regex is not. Regexes are not strings, they are code -- and with their syntax, they need comments even more.