简体   繁体   中英

Removing 1000s of comments in eclipse?

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

在此处输入图片说明

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

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM