有没有办法在PHP中重复捕获匹配?
<?php
$data = array();
preg_match_all("/^([\d]{1,2}?)(([\d]{2}))*([\d]{3})$/is", "987654321", $data);
print_r($data);
输出:
Array
(
[0] => Array
(
[0] => 987654321
)
[1] => Array
(
[0] => 98
)
[2] => Array
(
[0] => 54
)
[3] => Array
(
[0] => 54
)
[4] => Array
(
[0] => 321
)
)
[2]和索引中有错误。 预期产出是:
例如 987654321 应该捕获98,76,54,321,而 87654321 将执行8,76,54,321。