I essentially wish to match every line that DOES NOT contain this string "Hello"
我希望匹配不包含这个字符串"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++
基本上,我想使用notepad++删除不包含字符串“hello”的每一行
3 个解决方案
#1
4
(see update, below) Not all regex's are created equal - just because it works in one place doesn't mean it works in another. Always check the docs for the kind you're using.
(参见下面的更新)并不是所有的regex都是平等创建的——仅仅因为它在一个地方工作并不意味着它在另一个地方也可以工作。一定要检查你使用的文档。
In this case, there's no "!" operator. There may be other problems, too, that I haven't noticed.
在这种情况下,没有“!”操作符。可能还有其他问题,我没有注意到。
The hack I use for this situation is to do a "Find All In Current Document" for "hello", copy/paste the contents of the find window into a separate document, and remove the line numbers. There's got to be a better way - but till I find it, that's the best I have!
我用来做这种情况的hack是“查找所有当前文档”中的“hello”,将Find窗口的内容复制/粘贴到一个单独的文档中,并删除行号。一定有更好的办法——但在我找到它之前,那是我最好的办法!
The regex to get rid of the line numbers is "^ Line [0-9]+:
" - replace it with nothing, of course.
去掉行号的正则表达式是" ^[0 - 9]+行:“换成什么,当然可以。
Update: Version 6 of Notepad++ changed the regular expression engine to a Perl-compatible one, which supports "|". AFAICT, if you have a version 5., auto-update won't update to 6. - you have to explicitly download it.
更新:Notepad++的第6版将正则表达式引擎更改为与perl兼容的引擎,该引擎支持“|”。AFAICT,如果你有一个版本5。,自动更新不会更新到6。-你必须明确地下载。
#2
4
^((?!hello).)*$
works in Notepad++ 6. I wonder if it's better than this: ^(?!.*hello).*$
^((? !你好))*在记事本+工作+ 6美元。我想知道如果它是比这更好:^(? ! *你好)。*美元
#3
1
the new Version (I Recently updated to 6.2.2) has the ! operator implemented. I just tried it and it works.
新版本(我最近更新到6.2.2)有!操作符实现。我只是试了一下,效果很好。
#1
4
(see update, below) Not all regex's are created equal - just because it works in one place doesn't mean it works in another. Always check the docs for the kind you're using.
(参见下面的更新)并不是所有的regex都是平等创建的——仅仅因为它在一个地方工作并不意味着它在另一个地方也可以工作。一定要检查你使用的文档。
In this case, there's no "!" operator. There may be other problems, too, that I haven't noticed.
在这种情况下,没有“!”操作符。可能还有其他问题,我没有注意到。
The hack I use for this situation is to do a "Find All In Current Document" for "hello", copy/paste the contents of the find window into a separate document, and remove the line numbers. There's got to be a better way - but till I find it, that's the best I have!
我用来做这种情况的hack是“查找所有当前文档”中的“hello”,将Find窗口的内容复制/粘贴到一个单独的文档中,并删除行号。一定有更好的办法——但在我找到它之前,那是我最好的办法!
The regex to get rid of the line numbers is "^ Line [0-9]+:
" - replace it with nothing, of course.
去掉行号的正则表达式是" ^[0 - 9]+行:“换成什么,当然可以。
Update: Version 6 of Notepad++ changed the regular expression engine to a Perl-compatible one, which supports "|". AFAICT, if you have a version 5., auto-update won't update to 6. - you have to explicitly download it.
更新:Notepad++的第6版将正则表达式引擎更改为与perl兼容的引擎,该引擎支持“|”。AFAICT,如果你有一个版本5。,自动更新不会更新到6。-你必须明确地下载。
#2
4
^((?!hello).)*$
works in Notepad++ 6. I wonder if it's better than this: ^(?!.*hello).*$
^((? !你好))*在记事本+工作+ 6美元。我想知道如果它是比这更好:^(? ! *你好)。*美元
#3
1
the new Version (I Recently updated to 6.2.2) has the ! operator implemented. I just tried it and it works.
新版本(我最近更新到6.2.2)有!操作符实现。我只是试了一下,效果很好。