Documentation, Coding Style – Commenting Regular Expressions Effectively

coding-stylecommentsdocumentation

Are there any common practises for commenting the regular expressions: inline comments referring different part of RegEx or general comment for all expression?

Best Answer

In my view, a good practice is to concisely state in comments what the general idea of the regular expression is. This saves other developers (or sometimes yourself) the hassle of copy-pasting the regex in a parser like RegExr, only to understand what it does.

Related Topic