Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove All Comments in Java Files

Tags:

java

eclipse

I have many comments like following. Is there simple way to remove all comments?

IDE Eclipse Kepler

/* 34:   */

/*

 * JD-Core Version:    0.7.0.1

 */
like image 314
Ahmet Karakaya Avatar asked Sep 01 '25 17:09

Ahmet Karakaya


1 Answers

I have found the solution Regular Expression with multiple lines search.

Here are the regular expression used to find two types of comments

\/\*([\S\s]+?)\*\/ and (?s)/\*.*?\*/

Open the .java file with comments and open the Search dialog.(Search -> File Search) and paste one of the above reg-ex and check the Regular expression tick box on the right side. Now you can search and select "Replace All" to replace it with nothing typed in the second box.

Using replace-with option I have cleaned all comments from java files.

like image 69
Ahmet Karakaya Avatar answered Sep 04 '25 09:09

Ahmet Karakaya