Frame91
Frame91

Reputation: 3789

Regex for removing (non-Javadoc) @see comments?

Is there any chance to remove all comments with the following structure in the whole source-code:

/*
 * (non-Javadoc)
 * @see this.is.my.package.structure#overridenMethod()
 */
 @Override
 public void overridenMethod(){}

They were generated by eclipse automatically but it seems like they cannot be removed automatically as well.

What regular-expression would remove all these occurences?

Upvotes: 2

Views: 590

Answers (2)

Bohemian
Bohemian

Reputation: 425083

Treat the newlines as just more whitespace:

\s*/\*\s*\* \(non-Javadoc\)\s*\* @see \S+\s*\*/

See demo

Upvotes: 3

M A
M A

Reputation: 72864

Try this:

(?s)/\*[^\*].+?\*/

(?s) at the beginning is a flag to enable multiline matching.

[^\*] is used to skip catching two consecutive * which correspond to Javadoc-style comments.

Upvotes: 1

Related Questions