2 comments

[ 3.5 ms ] story [ 17.7 ms ] thread
Named groups are awesome.

I feel like the commented regular expression is actually harder to parse because of all the extra noise.

Maybe a good comment in the programming language’s native commenting syntax would be almost as effective? Even though comments often end up out of date, a good code review process for changes should include, “Did we update this comment to match the change to this RegEx?”

I also like to leave a commented link to RegExr with a direct URL to the regular expression in the playground so anyone can get a good, interactive breakdown, too. I know it could eventually experience bit rot, but as long as it exists it’s a great tool for explaining and exploring a regular expression’s syntax.

(comment deleted)