Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match c-style block comments in Notepad++ with a regex?

With the intent to match multiline comments, I found the following regex:

  (?:/\*(?:(?:[^*]|\*(?!/))*)\*/)

It is described here. It isn't perfect (it matches comments inside strings), but it works well enough for my purpose. However, it does not work in Notepad++. I tried escaping different things, but with no better results.

Does anyone know how to make this regex work in Notepad++?

like image 574
Greg Avatar asked Feb 25 '11 01:02

Greg


1 Answers

When the question was asked, the correct answer was that you couldn't do this in Notepad++, because its regex flavor didn't support regexes matching over multiple lines and lookahead (both of which are essential in the given regex).

However, Notepad++ has a much more powerful regex engine these days - since version 6.0 it supports full pcre regexes. This means your regex as given in the question just works. As such, I believe the correct answer would now just be "open the search menu, input your regex, choose regex for search mode and click search".

like image 95
Jasper Avatar answered Oct 29 '22 14:10

Jasper