Removing 1000s of comments in eclipse?

1.7k views Asked by At

I installed JD-GUI to retrieve my code from a jar file. Everything works fine, except JD-GUI automatically adds annoying comments like this:

enter image description here

Any way I can remove them? I don't understand regex.

3

There are 3 answers

0
Unihedron On BEST ANSWER

Use CTRL+H. Within "File Search" > "Search string", check "Regular expression" and use one of the regex given by the other answers.

Then use "Replace..." to replace them all with nothing.

0
ahuth On

Use the utility sed to search for a regex and replace with an empty string. Here is a gist that should get you started with using it.

Since you don't understand regex, I'll help you out with it: /^\/\* \d+ \*\//gm will find every comment block that starts at the beginning of a line and contains a line number.

Here's how it works:

  • / is the start of the regex
  • ^ matches the begnning of the line
  • \/\* finds the opening /* of the comment
  • (space) finds the space before the line number
  • \d+ finds any number of digits
  • (space) finds the space after the line number
  • \*\/ finds the ending */ of the comment
  • /gm ends the regex and flags this as a global, multiline search
2
savanto On

Using Eclipse:

Go to Edit > Find/Replace...
Use this regular expression in the Find box: ^/\* [0-9 ]{3} \*/

  • ^ match start of line.
  • /\* match start of comment
  • [0-9 ]{3} match exactly three digits/spaces
  • \*/ match end of comment

Make sure the Replace box is empty.
Make sure the Regular expressions checkbox is selected.
Click Replace All