谁能把网页中的图片提出来,并替换?(高分) 而且要把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> 大哥大姐们啊,PHP插入数据怎么一次只能插入126条? php 能实现 飞信功能吗 一个JS在IE和FireFox中执行效果 使用sleep(0)可以让PHP的循环执行更快吗? 如何获取分页显示的form表单的值? php-4.4.0RC1出来了。有没有发现什么大变化呢 如何读取文件的某部分代码? 谁知道UTF-8转GB2312函数 mysql数据库 在下正在学PHP4.0,可是 Apache+php4.0在我的机子上配置不起来,能否指教一下具体的配置方法吗?甚望!多谢了! 怎样实现网站的自动登陆功能?? 后台支持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>