1

the followings :

// comments

/****** comments *******/

is it possible to have a regex for them ?

revo
  • 47,783
  • 14
  • 74
  • 117
  • 2
    What about a line like `a = "This is // not a comment"`? Does the language you're using `/* allow /* nested */ comments */`? Are you aware that regular expressions in Notepad are line-based, so if comments span more than one line, it gets difficult? – Tim Pietzcker Oct 30 '11 at 09:34
  • more importantly i wanna capture _/* this */_ and replace it with blanks. – revo Oct 30 '11 at 09:47
  • What happens if you have /* in a string? It's not a comment. It's not possible to work with comments in a regex, it's beyond the abilities of it. – Ariel Oct 30 '11 at 09:50

4 Answers4

2

As the comments say, its not possible to strip comments in a correct way with regexes. But maybe its still enough for you to use the following regular expressions:

^\s*//.*$
/\*.*?\*/
morja
  • 8,297
  • 2
  • 39
  • 59
0

You can do this with a simple hack. Select Extended mode and then replace all \r\n with a character/character-sequence that does not occur in your file and that which will match .*. Now change back to Regular Expression mode and apply the regular expression (given by morja) to do your replace. Now replace back the special character/character-sequence with \r\n.

Narendra Yadala
  • 9,554
  • 1
  • 28
  • 43
0

@Mohammad Currently you cannot do this (match multiline) in Notepad++.

This is because matching newlines is possible in Extended search mode, and regular expressions are available in Regexp search mode.

You could however combine different steps and do what you want as pointed by other answers.

FailedDev
  • 26,680
  • 9
  • 53
  • 73
-2

The easiest solution is not to use regex from Notepad++, you sould only export as rtf (plugins --> nppexport --> export to RTF) then open with Microsoft Word or other that support format searching, so with that feature you can search and replace the green values only.

I hope it helps.

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
ahonig
  • 1