user1568531
user1568531

Reputation: 33

Find string NOT preceded by semicolon using Notepad++

In a directory with hundreds of xml-files, I need to find the files which contain the string nature where this string is not preceded by a semicolon on the same line.

For example:

It should find:

STATUS_OMS.PLUVOI = "NATURE"

It should NOT find:

; Horse Nature Product..

I'm rather new to regular expressions. I tried a lot, this once seems to come close, but the negation does not have the desired effect.

[^;].+?nature

Any pointers to what I'm doing wrong?

Please note that I'm using notepad++

Upvotes: 3

Views: 2340

Answers (2)

Wilbert
Wilbert

Reputation: 1818

Is this what you mean? It searches for lines up to and including the word nature that do not have a ; character before the word nature.

^[^;]+nature

Upvotes: 1

svinja
svinja

Reputation: 5576

You're looking for:

^[^;]*nature

which looks for a line starting with any number of non-semicolon characters followed by "nature".

Your regex:

[^;].+?nature

looks for exactly one non-semicolon character anywhere in a line, followed by one or more characters of any kind, followed by "nature".

Upvotes: 6

Related Questions