php正则表达式错误


Error with php regular expression

我有这样的代码:

$text = "###12###hello###43###good###113###thefinalstring";
preg_match_all('/(.*?)###('d*)###(.*?)/is', $text, $matches, PREG_SET_ORDER);

如果我转储$matches,为什么没有"thefinalstring"在任何地方?正则表达式中的错误在哪里?

谢谢

(.*?)###('d*)###(.*?)([a-zA-Z]*)

使用这个正则表达式

试一试:

$text = "###12###hello###43###good###113###thefinalstring";
preg_match_all('/###('d*)###([^#]*)/is', $text, $matches, PREG_SET_ORDER);
print_r($matches);
输出:

Array
(
    [0] => Array
        (
            [0] => ###12###hello
            [1] => 12
            [2] => hello
        )
    [1] => Array
        (
            [0] => ###43###good
            [1] => 43
            [2] => good
        )
    [2] => Array
        (
            [0] => ###113###thefinalstring
            [1] => 113
            [2] => thefinalstring
        )
)