Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php curl操作后需要Regex帮助_Php_Regex - Fatal编程技术网

Php curl操作后需要Regex帮助

Php curl操作后需要Regex帮助,php,regex,Php,Regex,我试图在curl操作后将regex与下面的html响应匹配(如果显示的话) Results: Displaying 1 of 1 entries 然后我有下面的代码设置 $pos = strpos($response, 'Results: Displaying 1 of 1 entries'); 我使用if($pos!==false)`来做一些事情 但是,如果搜索参数返回一组结果(大于1),我还需要匹配需要微调搜索参数的条件 所以类似于结果:显示X个条目中的1个,其中X大于1 什么正则表达

我试图在curl操作后将regex与下面的html响应匹配(如果显示的话)

Results: Displaying 1 of 1 entries
然后我有下面的代码设置

$pos = strpos($response, 'Results: Displaying 1 of 1 entries'); 
我使用
if
($pos!==false)`来做一些事情

但是,如果搜索参数返回一组结果(大于1),我还需要匹配需要微调搜索参数的条件

所以类似于
结果:显示X个条目中的1个
,其中X大于1


什么正则表达式可以与strop一起使用以匹配此条件

您必须使用preg_match():

您的正则表达式可能类似于:

Results: Displaying 1 of ([0-9]+) entries

要检查数字是否大于1,您必须比较第一个捕获的组,该组可以在数组中找到&$matches[1](第三个参数,请参阅php文档)。

您的意思可能是
[0-9]+
而不是
(0-9)+
Results: Displaying 1 of ([0-9]+) entries