【发布时间】:2015-05-08 00:31:07
【问题描述】:
我正在努力使用正则表达式进行文件搜索。
我正在寻找包含一个表达式但在文件下方不包含另一个表达式的文本文件。我正在为这一切的多线性而苦苦挣扎。
示例文件:
Here is a Target Phrase that I want to find and
here is a madeupword that if it is missing
means that the file is of interest.
我想查找表达式 Target Phrase 存在但 madeupword 不存在的文件。
我希望类似于
(Target Phrase)(?![.\s]*madeupword)
将是我所需要的,但没有快乐......
理想情况下,这将是 Visual Studio 2013 可以在“在文件中查找”对话框中处理的正则表达式,但我将采用 C# 正则表达式等效项,我可以在快速文件夹扫描控制台应用程序中使用。
【问题讨论】:
-
试试
(Target Phrase)(?![\S\s\r\n]*madeupword)。 -
看起来它在 C# 中完成了这项工作 - Visual Studio 仍然没有成功,但这对我来说已经足够了。把它作为回复,我会标记为答案。谢谢。
标签: c# regex visual-studio-2013