而且要把http://image2.sina.com.cn/home/images/sina_logo2.gif读出来

解决方案 »

  1.   

    这个好像可以用正则。
    <?
    $str="...";//省略文本
    preg_match_all("/src=(*.\.gif)/U",$str,$array);
    print_r($array);
    ?>
    以上是取得你要的东西,而替换呢?用到,一个preg_replace的函数,这在手册里好像可以找到。
      

  2.   

    不行阿,什么结果也没有
    $str='
    <html><img src=http://image2.sina.com.cn/home/images/sina_logo2.gif width=118 height=42></html>';
    preg_match_all("/src=(*.\.gif)/U",$str,$array);
    print_r($array);
      

  3.   

    对不起是我的失误,现在可以了。你试试。
    <?php 
    $str='
    <html><img src=http://image2.sina.com.cn/home/images/sina_logo2.gif width=118 height=42></html>';
    preg_match_all("/src=(.*\.gif)/U",$str,$array);
    print_r($array);print preg_replace("/(http.*\.gif)/U","http://www.abc.com/image/sina_logo2.gif",$str);
    ?>
      

  4.   

    <script language="JavaScript">
    <!--
    str="http://image2.sina.com.cn/home/images/sina_logo2.gif"
    alert(str.replace(/([\w\.]+\/)+/,'design.xuse.net/'))
    //-->
    </script>