5

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++?

Community
  • 1
  • 1
Greg
  • 34,042
  • 79
  • 253
  • 454
  • I think the problem is that Notepad++ doesn't apply regexes across multiple lines, which is what you're trying to do according to the linked question. It also doesn't support lookahead expressions. Use a better editor :) – Tim Pietzcker Feb 25 '11 at 08:37
  • oh...any suggestions? :) Notepad++ was good as it's lightweight and free... – Greg Feb 25 '11 at 09:50
  • what exactly do you want do to? see the matches, replace text, or what? – Oscar Mederos Feb 26 '11 at 05:20

2 Answers2

6

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".

Jasper
  • 11,590
  • 6
  • 38
  • 55
  • I highly recommend [EditPad Pro](http://www.editpadpro.com/) if you need to do this sort of thing a lot. The regular expression support is way better than any other editor I have ever used. – DaveRandom Jul 19 '13 at 13:50
4

Notepadd++ uses scintilla's regular expression engine (according to its online help).

This page says that "in Scintilla, regular expression searches are made line per line," so unfortunately I think it's hopeless.

-- EDIT --

A little further digging turned up this notepad++ forum post, which offers some hope after all. Specifically, it says that notepad++'s PythonScript plugin supports multiline regular expressions.

PaulF
  • 1,133
  • 8
  • 14
  • 1
    Just thought I'd add: since this post/question were added to this site, Notepad++ was updated to support these things. In fact, I blieve the regex might just work without anything special. – Jasper Jul 19 '13 at 03:12