私はこのコードを持っています:
$text = "###12###hello###43###good###113###thefinalstring";
preg_match_all('/(.*?)###(\d*)###(.*?)/is', $text, $matches, PREG_SET_ORDER);
$matches をダンプすると、「thefinalstring」がどこにもないのはなぜですか? 正規表現のどこにエラーがありますか?
ありがとう
私はこのコードを持っています:
$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
)
)