简体   繁体   English

Finder类php-搜索关键字问题

[英]Finder Class php - search keywords issue

I am working on symfony 2.7 and i am using finder class of php. 我正在使用symfony 2.7,正在使用php的finder类。

I am searching more then 1 keyword in the list of files. 我正在文件列表中搜索1个以上的关键字。

I don't have any idea how to search more then 1 keyword using "contains" method of the finder class. 我不知道如何使用finder类的“ contains”方法搜索1个以上的关键字。

Below is my sample code. 以下是我的示例代码。

$value = 'Leo Tiger';

$finder = new Finder();
$finder->in()->files()->contains($value);

My Concern is that i want to search "Leo" and "Tiger" both separately in diff files like elastic search will do. 我担心的是,我想像弹性搜索一样在差异文件中分别搜索“狮子座”和“老虎”。

How to use wildcard in finder method ? 如何在finder方法中使用通配符?

I will really appreciate if anyone can help me this. 如果有人可以帮助我,我将非常感谢。

As you can see in comment to function contains the parameter $pattern can be (string or regexp). 正如你可以到功能评论看到包含参数$模式可以是(字符串或正则表达式)。 You can try use regex to find keywords Leo or Tiger: 您可以尝试使用regex查找关键字Leo或Tiger:

$finder = new Finder();
$finder->in($dir)->files()->contains('/Leo|Tiger/');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM