notepad++ Inverse Regex replace (all but string)

大城市里の小女人 提交于 2019-11-26 16:36:04

问题


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.



来源:https://stackoverflow.com/questions/8264391/notepad-inverse-regex-replace-all-but-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!