Regex (with negative look-forward) not returning expected result

I am using the following regex in a Search and Replace Variable Action:

Search: ^(?!(.+Text.+1960.+[^o]$)).*$\n
Replace: {null}

(I change “Text” and “1960” as needed for these data sets. I need to filter out lines ending in the letter “o”.)

This pattern produces the expected result — only lines which contain “…Text…1960…” and end in a character other than “o” are retained — in both RegExRX (a program for writing and testing regex’s) and in jEdit (a text editor with an advanced search/replace engine).

I cannot get it to work in KM. I have tried both “case sensitive” and “ignoring case”. I have tried it without the end-of-line character.

I’m out of trouble-shooting ideas.

(20.Sep.2015: edited to make verbal description of regex action clearer.)

Hey Kirby,

(?m)^(?!(.+Text.+1960.+[^o]$)).*$\n

Keyboard Maestro's ICU regex doesn't do multi-line by default. You have to switch it on.

-Chris

2 Likes

Huzzah!!

Many thanks :blush: .