PHP 选择最后 5 或 6 个带空格/不带空格的数字


php select last 5 or 6 numbers with/without space

我的数据如下所示:

John 123 45
Doe 67890
Elly Clarkson 111 22
Chris Man Wu 44455
some92 thing91103
make1too 12120
make1too45100

如何获取最后 5 或 6 位数字,两者之间有或没有空格?

结果应为:

123 45
67890
111 22
44455
91103
12120
45100
$data="John 123 45
Doe 67890
Elly Clarkson 111 22
Chris Man Wu 44455
some92 thing91103
make1too 12120
make1too45100";
preg_match_all('/[a-z ]*([0-9 ]{5,6})/i', $data, $result);
$result = $result[1];
print_r( $result);
preg_match_all('|(?=.{5,6}$)'d+[ ]?'d+$|m', $input, $matches, PREG_SET_ORDER);

查看此演示