2

is there a way in Notepad++ (whether by Regex or some other way) to replace/remove comments within curly brackets?

{ some comments { nested comments } need to be deleted }

I want to remove the comments inside, or completely remove the comments including the braces. Not sure if there is an easy way to to do this. Any help is greatly appreciated.

Swoop
  • 43

1 Answers1

1

You can use the regular expression \{[^{}]*\} to find (and replace with nothing) all inner { nested comments }. \{ matches open bracelet, [^{}]* matches anything except for { and }, and \} matches the closing bracelet.

If you want to remove the outer comments, simply repeat the replace action. After removing the inner comments, the nested comments become single level comments which can be removed with the regular expression.

Alternatively, you can use the regular expression \{([^{}]*|\{[^{}]*\})*\} to find and replace one level or two level comments. Unfortunately, as notepad++ regular expression does not support recursion, you cannot remove arbitrary level of nested comments in one go.

Kenneth L
  • 14,104