0

私はこのコードを持っています:

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

$matches をダンプすると、「thefinalstring」がどこにもないのはなぜですか? 正規表現のどこにエラーがありますか?

ありがとう

4

2 に答える 2

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

この正規表現を使用

于 2013-06-06T15:21:15.730 に答える
0

試してみてください:

$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
        )

)
于 2013-06-07T10:11:44.927 に答える