日期:2014-05-17  浏览次数:20512 次

求一正则匹配的PHP代码
http://e.hiphotos.baidu.com/baike/s%3D220/sign=6c84b182baa1cd1101b675228913c8b0/a50f4bfbfbedab6497171872f736afc379311e1e.jpg

http://h.hiphotos.baidu.com/baike/s%3D220/sign=b3f3516701e9390152028a3c4bed54f9/d058ccbf6c81800ad6f26049b13533fa828b4766.jpg

http://g.hiphotos.baidu.com/baike/s%3D220/sign=f1457cf21f30e924cba49b337c096e66/f7246b600c3387441db54e86510fd9f9d62aa0dc.jpg

把红色部分匹配出来~~
------解决方案--------------------
<?php 
$str = '<img class="card-image editorImg log-set-param" alt="陈晓东" src="http://e.hiphotos.baidu.com/baike/s%3D220/sign=6c84b182baa1cd1101b675228913c8b0/a50f4bfbfbedab6497171872f736afc379311e1e.jpg" title="陈晓东" log-set-param="img_view" onload="this.parentNode.parentNode.style.width=this.width+px"/>';
preg_match('/<img.*\/(\w+\.jpg)"/', $str, $match);
var_dump($match[1]);
?>