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

With the intention of matching multi-line comments, I found the following regular expression:

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

It is described here. This is not ideal (it matches the comments inside the lines), but it works well enough for my purpose. However, in Notepad ++ this does not work. I tried to get away from different things, but without the best results.

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

+4
source share
2 answers

Notepadd ++ uses the scintilla regex engine (as per its online help).

This page says that β€œin Scintilla, regular expression searches are performed on line by line,” so unfortunately I find this hopeless.

- EDIT -

This post on the notepad ++ blog, which has some hope, has gone a little further than digging. In particular, he says the notepad + PythonScript plugin supports multi-line regular expressions.

+3
source

When the question was asked, the correct answer was that you could not do it in Notepad ++ because its regular expression flavor did not support regular expressions matching multiple lines and lookahead (both of which are needed in this regular expression).

However, Notepad ++ has a much more powerful regex engine these days - as version 6.0 supports full pcre regexes. This means that your regex, as stated in the question, just works. Thus, I believe that the correct answer will now be simply "open the search menu, enter your regular expression, select the regular expression for the search mode and click" Search ".

+6
source

Source: https://habr.com/ru/post/1341247/


All Articles