19

I am trying to match the lines in following not input NOT containing "VelSign" (using Notepad++):

#MARKER VelSign 457.45 50 kmh

#MARKER IsBridge true

#MARKER TrafficSign 45

#MARKER TrafficLight 45 445 444 40

I am using the following regex: ^#MARKER (?!.*VelSign).*$

Doesn't seem to work. What am I doing wrong?

Community
  • 1
  • 1
Mihai Galos
  • 1,707
  • 1
  • 19
  • 38

2 Answers2

11

Make sure that you upgrade Notepad++ to version 6, as they changed quite a lot in the regex engine. Especially line breaks and lookarounds were a bit problematic in earlier versions.

Community
  • 1
  • 1
Martin Ender
  • 43,427
  • 11
  • 90
  • 130
  • sorry about the typo. My regex is : ^#MARKER (?!.*VelSign).*$ – Mihai Galos Jun 03 '13 at 20:29
  • @MihaiGALOS that works for me. what is it matching for you? (or what is it not matching) – Martin Ender Jun 03 '13 at 20:30
  • Thanks for the quick feedback. Notepad++ says: Cannot find the text "^#MARKER (?!.*VelSign).*$" – Mihai Galos Jun 03 '13 at 20:34
  • @MihaiGALOS have you activated regex mode and have you upgraded to the most recent version of Notepad++? Before version 6 there were some significant shortcomings of the regex engine. Also, is the `#` right at the beginning of your lines? If not, add in `\s*` between `^` and `#`. – Martin Ender Jun 03 '13 at 20:35
  • 1
    The regex was good indeed! I upgraded before asking the question but it only upgraded to 5.9.2 Thank you for the reply. Please post another answer so I can validate it. – Mihai Galos Jun 03 '13 at 20:40
11

Turn this:

^#MARKER (?!.\*VelSign).*$

Into this:

^#MARKER (?!.*VelSign).*$

You are escaping the * operator, which causes the match of a literal * instead of 0 or more ..

Also, make sure that you have checked the RegularExpression option (see the third radio button):

enter image description here

Jerry
  • 70,495
  • 13
  • 100
  • 144