I had to quickly remove single line comments from an Android project in Eclipse. I could not find any built in feature in Eclipse to do that. So I resorted to a simple regular expression:

(//[^\n]*)

This simple regex selects all the strings that begin with “//” and end with a new line. So all you have to do is use it in the find and replace option for a file or to apply to the whole project or multiple files do Search -> File. Also, make sure to select the “regular expression” check box.

This is something I did very quickly… so be careful since it might pick up some urls as well… like anything after the “//” part in “http://mysite.com/page.php”.

Quick and easy way to remove all single line (//) comments in Eclipse

2 thoughts on “Quick and easy way to remove all single line (//) comments in Eclipse

  • June 17, 2013 at 3:19 pm
    Permalink

    Thank you so much. really fast and helpfull

  • December 5, 2016 at 12:49 am
    Permalink

    thank you.

    i am change regular expression.

    ([^:]//[^\n]*)

    it’s pass “http://…”

Leave a Reply

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

*