php正则表达式提取字符串

时间:2015-06-03 11:21:46

标签: php regex preg-match-all multiple-matches

我使用php preg_match_all测试了几个小时来提取数据,但没有运气。

原始数据:

"media":{"content":[{"url":"zz.abc.com/-5vPApXfHhjw/VWsfGkM05jI/AAAAAAAAABI/qr6IodAAnJg/heyzo_hd_0870_full-cut.gif","height":288,"width":512,"type":"image/gif"},{"url":"zz.abc.com/lZY0lTdOkOLn-uwa_Qkgt_ywfmnxV1B9qfzAur_KQw=m19","height":360,"width":640,"type":"video/mpeg4"},{"url":"zz.abc.com/lZY0lTdOkOLn-uwa_Qkgt_ywfmnxV1B9qfzAur_KQw=m28","height":720,"width":1280,"type":"video/mpeg4"},{"url":"zz.abc.com/lZY0lTdOkOLn-uwa_Qkgt_ywfmnxV1B9qfzAur_KQw=m39","height":1080,"width":1920,"type":"video/mpeg4"}],"description":"","

我想提取: zz.abc.com/lZY0lTdOkOLn-uwa_Qkgt_ywfmnxV1B9qfzAur_KQw=m19

zz.abc.com/lZY0lTdOkOLn-uwa_Qkgt_ywfmnxV1B9qfzAur_KQw=m28

zz.abc.com/lZY0lTdOkOLn-uwa_Qkgt_ywfmnxV1B9qfzAur_KQw=m39

我用:

preg_match_all("/(?<!\[\{\"url\":\")(zz\.abc\.com)(.*?[a-zA-Z]\d\d)(?=\",\"height\")/", $html, $matches);

if ($matches[0][1]!=""){
echo $matches[0][1];
}
if ($matches[0][2]!=""){
echo $matches[0][2];
}
if ($matches[0][3]!=""){
echo $matches[0][3];
}

请告知如何输出我的数据,非常感谢。

0 个答案:

没有答案