我想使用Notepad ++中的"在当前文档中查找全部"按钮来查找单词列表的所有实例.是否可以使用正则表达式执行此操作?
例如,如果单词列表是
Foo,man,choo
Run Code Online (Sandbox Code Playgroud)
和包含在notepad ++中的文件
01 The quick brown fox jumps over the lazy dog
02 The quick brown fox jumps over the lazy dog
03 The quick brown man jumps over the lazy dog
04 The quick brown fox jumps over the lazy dog
05 The quick brown fox jumps over the lazy dog
06 The quick brown foo jumps over the lazy dog
07 The quick brown fox jumps over the lazy dog
08 The quick brown fox jumps over the lazy dog
09 The quick brown choo jumps over the lazy dog
10 The quick brown fox jumps over the lazy dog
Run Code Online (Sandbox Code Playgroud)
将在查找结果中返回第3,6和9行.
zes*_*ssx 11
|自6.1.1版本以来,Notepad ++支持管道运算符.
您可以使用此正则表达式进行搜索:
^.*(Foo|man|choo).*$
Run Code Online (Sandbox Code Playgroud)
如果您只想匹配这些单词,那么您可以使用
(foo|man|choo)
Run Code Online (Sandbox Code Playgroud)
结果:
foo
man
choo
Run Code Online (Sandbox Code Playgroud)
但是如果你想匹配整个行,其中包含你可以使用的其中一个单词
^.*(foo|man|choo).*$
Run Code Online (Sandbox Code Playgroud)
结果:
03 The quick brown man jumps over the lazy dog
06 The quick brown foo jumps over the lazy dog
09 The quick brown choo jumps over the lazy dog
Run Code Online (Sandbox Code Playgroud)