🔍Regex Recipes

Find TODO/FIXME Comments

Scan code for TODO, FIXME, HACK, and NOTE comments.

Pattern

(TODO|FIXME|HACK|NOTE|XXX):?\s*(.*)$

Explanation

Matches common code comment markers with optional colon and captures the rest of the line.

Examples

TODO comment
Input
// TODO: Fix this bug
Output
✓ Match: TODO: Fix this bug
FIXME
Input
# FIXME urgent
Output
✓ Match: FIXME urgent
Multiple
Input
/* NOTE: Important */
// TODO refactor
Output
Matches both

Code Examples

JavaScript
// Find all TODO markers in code
const code = `
// TODO: Refactor this function
function old() {
  // FIXME: Memory leak here
  // NOTE: This is important
}
`;

const todos = [...code.matchAll(/(TODO|FIXME|HACK|NOTE|XXX):?\s*(.*)$/gm)];
todos.forEach(([full, type, message]) => {
  console.log(`${type}: ${message}`);
});

Try it Now

💡 Tips

  • Add to pre-commit hooks to track technical debt
  • Use IDE plugins for better TODO tracking
  • Include @username for assignment: TODO(@john)
  • Add HACK for temporary workarounds

⚠️ Common Pitfalls

  • May match TODOs in strings or comments you want to keep
  • Different languages have different comment syntaxes
  • Consider context - not all TODOs are urgent
  • May want to extract line numbers too