Press "Enter" to skip to content

Finding commented out code

To find commented out code, the key is to remember that commented out code will usually contain semicolons.

If you keep that in mind, it is quite simple to come up with regular expressions to search for commented out code.

For single line comments:
(?s://[^/]+;)

and for multiple line comments:
(?s:/*[^/]+;)

These regular expressions won’t necessarily find every line of commented out code, but they should find every block.