Oguz Özkeroglu
Oguz Özkeroglu

Reputation: 3057

Eclipse Find/Replace with Regex to comment lines

I have some classes that contains comments like as follow:

...
...
...
/*     */ 
/*     */   public void startApplication()
/*     */   {
/*  57 */     initializeFields();
/*  58 */     this.run = true;
/*  59 */     new Thread(this).start();
/*     */   }
/*     */ 
/*     */   public void stopApplication() {
/*  63 */     this.run = false;
/*     */   }
/*     */ 
/*     */   public void run()
/*     */   {
...
...
...

And i have to clean all /* */ strings in my classes. Which regex should i use to do this with using Eclipse's Find/Replace tool?

Upvotes: 4

Views: 3672

Answers (3)

Mehdi
Mehdi

Reputation: 1531

Hit CTRL+SPACE on the text boxes it will give you suggestions for regular expressions. You can fin more details in this discussion

Upvotes: 1

LeonardChallis
LeonardChallis

Reputation: 7783

You can use: /\*\s+\d*\s+\*/, or if you also want to strip the space before the code, presuming it's a tab, use /\*\s+\d*\s+\*/\t. Optionally change that last tab for a specific number of spaces - if you just use \s+, for instance, it will lose your indentation, which you don't want!

Upvotes: 0

Marko Topolnik
Marko Topolnik

Reputation: 200148

This is Jd-GUi, I've already needed the same regex :)

/\*.*?\*/

Upvotes: 8

Related Questions