Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.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
如何regexp PHP查找字符串中的数字_Php_Regex_String_Split_Preg Match All - Fatal编程技术网

如何regexp PHP查找字符串中的数字

如何regexp PHP查找字符串中的数字,php,regex,string,split,preg-match-all,Php,Regex,String,Split,Preg Match All,我对regexp有问题,我正在寻找解决这个问题的方法 我需要在文本中查找超过3位的数字,但我需要忽略数字在开始/最后$字符上的位置 示例: Lorem ipsum dolor32sit32181527amet,Concertetur Adipising18312.90美元,2432417美元 关于结果,我只想得到这个数字32181527 我知道如何获取数字,但当is$出现时,我不能忽略 [0-9]{3,} 使用,可以限制不在特定模式之前/之后的匹配: $text = "Lorem ipsum

我对regexp有问题,我正在寻找解决这个问题的方法

我需要在文本中查找超过3位的数字,但我需要忽略数字在开始/最后$字符上的位置

示例:

Lorem ipsum dolor32sit32181527amet,Concertetur Adipising18312.90美元,2432417美元

关于结果,我只想得到这个数字32181527

我知道如何获取数字,但当is$出现时,我不能忽略

[0-9]{3,}
使用,可以限制不在特定模式之前/之后的匹配:

$text = "Lorem ipsum dolor 32 sit 32181527 amet, consectetur adipiscing $18312.90, 2432417$.";
preg_match_all('/(?<![0-9$])[0-9]{3,}(?![0-9$])/', $text, $matches);
// match 3+ digits which is not preceded by digits/$.
// also the digits should not be followed by digits/$.
print_r($matches);
Array
(
    [0] => Array
        (
            [0] => 32181527
        )

)