Deleting comments through regular expressions in idea

Type CTRL+F in the search box in idea

\/\*\*(\s|.)*?\*\/

 

\s : matches invisible characters

. : matches any single character except '\n'

? : When the character immediately follows any one of the other qualifiers (*,+,?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. Match fewer characters.

 

 

Search bar uses regular expressions to search

 

(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/|[ \t]*//.*)
The code that will search for all comments can be replaced with spaces.

 

or search

 

(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)
Just search for the first and last comments

 

 

Also searching for whitespace lines is

\n\n

Then global replace can remove the code space line.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326096307&siteId=291194637