谁能把网页中的图片提出来,并替换?(高分) 而且要把http://image2.sina.com.cn/home/images/sina_logo2.gif读出来 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个好像可以用正则。<?$str="...";//省略文本preg_match_all("/src=(*.\.gif)/U",$str,$array);print_r($array);?>以上是取得你要的东西,而替换呢?用到,一个preg_replace的函数,这在手册里好像可以找到。 不行阿,什么结果也没有$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); 对不起是我的失误,现在可以了。你试试。<?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);?> <script language="JavaScript"><!--str="http://image2.sina.com.cn/home/images/sina_logo2.gif"alert(str.replace(/([\w\.]+\/)+/,'design.xuse.net/'))//--></script> select默认值 mysql备份时出错 {php求助} PHP 登陆使用超链接的问题 如何看出一个网站是用什么技术实现,用什么服务器和操作系统和数据库? 统一登录问题,头大! 如果当前cookie中的值为0 某些div不显示 怎么写 新手请教有关Session的问题! 如何在submit之前做验证? 如何在程序里 模拟 get 方法提交数据,并得到返回结果。 第一个程序就出错了! 怎样实现网站的自动登陆功能?? 后台支持PHP的嵌入式Word,Excel编辑器示例源代码下载!(使用演示版本控件)
<?
$str="...";//省略文本
preg_match_all("/src=(*.\.gif)/U",$str,$array);
print_r($array);
?>
以上是取得你要的东西,而替换呢?用到,一个preg_replace的函数,这在手册里好像可以找到。
$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);
<?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);
?>
<!--
str="http://image2.sina.com.cn/home/images/sina_logo2.gif"
alert(str.replace(/([\w\.]+\/)+/,'design.xuse.net/'))
//-->
</script>