Me writing a (mildly complex) regular expression 4 months ago to validate a user input:
"Haha fuck yeah!!! Yes!!"

Me debugging an obscure, arcane regular expression I wrote 4 months ago:
"Well this fucking sucks. What the fuck."

@chriskirknielsen Sometimes a 20-character regular expression needs a 20-line comment. What it does, what it doesn't do, what else you tried & why that didn't work...

@AmeliaBR For real! Especially when working with others who maybe aren't so interested in learning the regex incantations, but even for myself it's handy.

Sometimes I'd annotate each capture group/sequences with a number on the line above the regex, ASCII-style, and a comment block would detail what each thing does, but only for big ones. I'd otherwise write a comment that explains what it does, with an example, which, luckily, helped me debug this time around. 😅

@chriskirknielsen
Write as if _you're_ the poor SOB who will have to maintain this thing a decade from now...

(Every once in a while I'll trip across some weird head-scratcher of a controls system problem, do an online search, find a fifteen-year-old forum post that solves the problem for me, and realize it was a love letter to my future self...)

@PhilSalkie Definitely the right approach! I try to comment at every turn, but at times a little more lightly than others… got it figured out though, luckily.
@chriskirknielsen @PhilSalkie I use one of those regex analyzers from 10 years ago, gives you a diagram enough to relearn what the regex does