notepad++ Inverse Regex replace (all but string)

2019-01-11 20:29发布

问题:

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

回答1:

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



回答2:

the new Version (I Recently updated to 6.2.2) has the ! operator implemented. I just tried it and it works.