Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2020-12-04 05:50
Flavor·JavaScript

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

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