Find code comments using regex in an IDE

So if you are a developer,  you might need to clean up comments from a code that you might have copied from somewhere else and updating the documentation needs you to start from scracth, or you just want to get rid of comments. Afterall, it can’t be called code if can be understood. Just kidding!

For Javascript and C/C++ or PHP comments or basically any language that uses this syntax for comments

/* Your comment goes here*/


* Your comments here
* Your comments here again

the search query would be like:


just make sure to select regex like I did in my case in the screenshot below, so search with the following and replace with

Regex checkbox in PhpStorm IDE

Regex checkbox in PhpStorm IDE

For HTML comments, you’d use something along these lines for the regex pattern for your search and replace query

\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>

no responses for Find code comments using regex in an IDE

    Leave a Reply

    Your email address will not be published. Required fields are marked *