Regular Expressions 101

Community Patterns

TODO comments, with optional `(author):` style author tag postfix capture

0

Regular Expression
ECMAScript (JavaScript)

/
(@TODO)(?:(?:([\(])((?:(?:[^\)\n\/\*]+)|(?:(?<!\*)[\/]|\*(?!\/))+)+)([\)]))?(:))?
/
gm

Description

Capture groups fully cover captured characters with no overlaps, designed for any language with line comments or /*, */ style block comments.

Validation is kept to a reasonable level to avoid high parsing time:

  • Comment context is not validated with lookbehind
  • Parenthesized author name block validates that a closing */ is not passed
Submitted by disk0 - 3 years ago