如何使用“在文件中查找”在Delphi中执行布尔“AND”搜索?

时间:2022-06-21 04:46:59

Now that my code is getting ever larger, a strategy to locate key code locations is more important. With faster PC's now, 'Search' 'Find in Files' is quick and effective - 'Search all files in project' often does not work if you have used implicit units. I've struggled to understand regular expressions but presumably they would let me do a search like:

现在我的代码越来越大,找到关键代码位置的策略更为重要。现在有了更快的PC,'搜索''在文件中查找'快速有效 - 如果您使用隐式单元,“搜索项目中的所有文件”通常不起作用。我一直在努力理解正则表达式,但可能他们会让我做一个搜索:

one OR two

一个或两个

one AND two

一个和两个

All searches are required to be on the same line.

所有搜索都必须在同一行。

This would be a great improvement on a simple keyword search. Is this possible in Delphi's search? I'm using XE, XE2 and D7 (sometimes).

这对于简单的关键字搜索来说是一个很大的改进。在Delphi的搜索中这可能吗?我正在使用XE,XE2和D7(有时候)。

1 个解决方案

#1


6  

The regular expression you need to search for one or two is

您需要搜索一个或两个的正则表达式是

one|two

The | symbol means or in regex speak.

|符号表示或正则表达。

Searching for a file containing both one and two is more difficult since the search is line-oriented. You could search for one and two on the same line like this:

搜索包含一个和两个的文件更加困难,因为搜索是面向行的。您可以在同一行搜索一个和两个,如下所示:

one.*two|two.*one

#1


6  

The regular expression you need to search for one or two is

您需要搜索一个或两个的正则表达式是

one|two

The | symbol means or in regex speak.

|符号表示或正则表达。

Searching for a file containing both one and two is more difficult since the search is line-oriented. You could search for one and two on the same line like this:

搜索包含一个和两个的文件更加困难,因为搜索是面向行的。您可以在同一行搜索一个和两个,如下所示:

one.*two|two.*one