<dd> http://***.***.**/**/**/4_img/***_**/***_******_******.jpg</dd>
以上是字符串,我想提取含有4_img的图片,请高手帮忙,兄弟言谢了。要求是PHP

解决方案 »

  1.   

    1.通过正则获取到含有4_img的所有的图片地址
    2.循环file_get_contents图片地址 并file_put_contents到本地
      

  2.   


    preg_match_all("/http:\/\/.+?4_img[^\.]+?\.jpg/",$str,$match);print_r($match);
      

  3.   

    怎么我打印是这样的。
    Array ( [0] => Array ( [0] => http://***.***.**/**/**/4_img/***_**/***_******_******.jpg ) ) 
      

  4.   

    有一点瑕疵,因为可能误判
    <dd> http://***.***.**/**/**/24_img/***_**/***_******_******.jpg</dd>
    <dd> http://***.***.**/**/**/a04_imgbox/***_**/***_******_******.jpg</dd>
    这种,所以前后最好多增加限定,4_img限定扩充为/4_img/
    楼主的例子里面,估计就容易出现数字末尾4这种误判PHP code//preg_match_all("/http:\/\/.+?4_img[^\.]+?\.jpg/",$str,$match);
    preg_match_all("/http:\/\/.+?\/4_img\/[^\.]+?\.jpg/",$str,$match);
    print_r($match);