notepad++ Inverse Regex replace (all but string)

user1064906 picture user1064906 · Nov 25, 2011 · Viewed 22.5k times · Source

I essentially wish to match every line that DOES NOT contain this string "Hello"

Example:

sdfsdoifdoskf
fdgokfdghodfkg
hello
fdojgohdfgjkdfg
gfobjobhkdfokgdfg
dofjkdsf hello dfgkdfogdfg
xcvmxhckvmxck
fogkdfhokg
hello

I attempted this Regex pattern : ^((?!hello).)*$

No matches found.

Basically i want to remove every line that does not contain the string "hello" using notepad++

Answer

Cees Timmerman picture Cees Timmerman · May 30, 2016

^((?!hello).)*$ works in Notepad++ 6. I wonder if it's better than this: ^(?!.*hello).*$