1
我使用PHP preg_match_all
提取這樣的消息的某些部分:PHP preg_match_all沒有得到所有的結果
$customerMessage = '"message":"success:2,2;3,3;"' ;
preg_match_all('/("message":")([a-z0-9A-Z]+):([0-9]+,[0-9]+;)+/', $customerMessage, $matches);
var_dump($matches);
die;
這段代碼的輸出是:
array(4) {
[0]=>
array(1) {
[0]=>
string(27) ""message":"success:2,2;3,3;"
}
[1]=>
array(1) {
[0]=>
string(11) ""message":""
}
[2]=>
array(1) {
[0]=>
string(7) "success"
}
[3]=>
array(1) {
[0]=>
string(4) "3,3;"
}
}
爲什麼不能我得到部分2,2;
? 在此先感謝!
你只能得到最後的一個組的匹配!謝謝。你是對的! – Abadis