Notepad++ 如何使用记事本++;在文件中搜索以显示特定行
我试图在我拥有的多个文件中查找特定行。所有文件都具有相同的开始/结束字符串以查找它们之间的行。 我试图显示第一个搜索字符串“项目:”和第二个搜索字符串“完成项目”之间的所有行 我不知道如何使用正则表达式 如果你能提供我需要输入的具体搜索,我将非常感谢你 例如:Notepad++ 如何使用记事本++;在文件中搜索以显示特定行,notepad++,Notepad++,我试图在我拥有的多个文件中查找特定行。所有文件都具有相同的开始/结束字符串以查找它们之间的行。 我试图显示第一个搜索字符串“项目:”和第二个搜索字符串“完成项目”之间的所有行 我不知道如何使用正则表达式 如果你能提供我需要输入的具体搜索,我将非常感谢你 例如: items: box bottle briefcase items done items: car cradle candle done items items: door desk done items 假设第一个块以done i
items:
box
bottle
briefcase
items done
items:
car
cradle
candle
done items
items:
door
desk
done items
假设第一个块以
done items
结束,而不是items done
- Ctrl+H
- 查找内容:
^items:\s+\K[\s\s]+?(?=^done items)
- 检查环绕
- 检查正则表达式
- 找到下一个
^ # beginning of line
items: # literally
\s+ # 1 or more spaces (including linebreaks
\K # forget all we have seen until this position
[\s\S]+? # 1 or more any character, not greedy
(?=^done items) # positive lookahead, make sure we have "done items" at the beginning of line
截图(第一场比赛):
^ # beginning of line
items: # literally
\s+ # 1 or more spaces (including linebreaks
\K # forget all we have seen until this position
[\s\S]+? # 1 or more any character, not greedy
(?=^done items) # positive lookahead, make sure we have "done items" at the beginning of line
截图(第二场比赛):
^ # beginning of line
items: # literally
\s+ # 1 or more spaces (including linebreaks
\K # forget all we have seen until this position
[\s\S]+? # 1 or more any character, not greedy
(?=^done items) # positive lookahead, make sure we have "done items" at the beginning of line
…等等,当您单击“查找下一步”时,您的第一个块以“已完成的项目”而不是“已完成的项目”结束,这是打字错误吗?谢谢您的帮助,我正在尝试在“文件搜索”中执行此操作。扫描许多txt文件。而且这个功能没有环绕。我该怎么办?在搜索文件中使用此命令时,每个文件只显示一行。它应该让我看到更多that@EladNa:这就是Npp的工作方式,它只显示匹配块的第一行。也许你应该写一个脚本。你到底想做什么?编辑您的问题并添加一些示例文件,实际上,您只显示了一个文件。我有10000多个包含不相关文本的txt文件。但在大约30%的文件中,我有需要提取到一个大txt文件的信息。我需要搜索所有这些文件谁有我需要的信息,并显示在搜索结果中,所以我可以复制他们。所有包含数据的文件都有相同的开始行和结束行,让我们举个例子:文件1:名称alvin james owen endfile 2:chris nathan end file 3 moses steve jose jim brad harrison end我需要“名称”和“结束”之间的所有信息,无论它们有多少行,都将显示在搜索结果中。有时是1行,有时是8行。谢谢你的帮助