Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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中的文本_Php_Regex - Fatal编程技术网

使用正则表达式解析PHP中的文本

使用正则表达式解析PHP中的文本,php,regex,Php,Regex,使用PHP,如何从文本中删除所有内容,并仅获得165 (我需要在165的位置获得任何号码) “luminara无焰蜡烛”165项结果中的1-16项 使用preg_match功能: $s = '1-16 of 165 results for ""luminara flameless candles""'; preg_match('/\bof ([0-9]+) results/', $s, $m); print_r($m[1]); 输出: 165 正则表达式:\d+(?=结果)

使用PHP,如何从文本中删除所有内容,并仅获得165

(我需要在165的位置获得任何号码)

“luminara无焰蜡烛”165项结果中的1-16项


使用
preg_match
功能:

$s = '1-16 of 165 results for ""luminara flameless candles""';
preg_match('/\bof ([0-9]+) results/', $s, $m);
print_r($m[1]);
输出:

165
正则表达式:
\d+(?=结果)