高手帮忙看看这个正则该如何写才行? /<sohu*<\/sohu/i ===>/<sohu.*<\/sohu/i 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /<sohu.*<\/sohu/i这样还是不行/<sohu.[^<]*<\/sohu/i这样才行不知为什么? /<sohu_cms_include:.*<\/sohu_cms_include>/ /<sohu_cms_include:(.*)<\/sohu_cms_include>/Ui 都不行啊!$ttt =<<< eoftest<sohu_cms_include:learning_articlefrag1><p align=center><a href=http://2004.sports.sohu.com/ target=_blank><font color=red><b>搜狐奥运王者归来,七种武器谁与争锋</b></font></a> <a href=http://2004.sports.sohu.com/ target=_blank><img src="http://photo.sohu.com/20040809/Img221437781.gif" height="10" border=0></a></p> </sohu_cms_include>eof;echo $opf = preg_replace("/<sohu[.\n]*<\/sohu/i","",$ttt);结果还是老样子. 上面代码不对$ttt = < < < eof test <sohu_cms_include:learning_articlefrag1><p align=center ><a href=http://2004.sports.sohu.com/ target=_blank > <font color=red > <b >搜狐奥运王者归来,七种武器谁与争锋 </b > </font > </a > <a href=http://2004.sports.sohu.com/ target=_blank > <img src= "http://photo.sohu.com/20040809/Img221437781.gif " height= "10 " border=0 > </a > </p > </sohu_cms_include> eof; echo $opf = preg_replace( "/ <sohu[.\n]* <\/sohu/i ", " ",$ttt); 里面包含\n的情况所以要[.\n],但就是不行! .本来就不匹配\n,在PHP中可以通过/s来使它匹配 对的,用s模式echo $opf = preg_replace("/<sohu(.*)<\/sohu/s","",$ttt); 不用s模式就象cloudchen(cloudchen) 那样 php 访问slice文件 Ice_loadProfile版本不兼容问题求助 php顯示圖片問題 PHP框架问题 请问我为什么无法获得循环结果 文件操作问题 大家给推荐一个把mysql数据导入oracle的工具 使用post方法的问题 菜鸟问题,请问高手,有的php编辑软件有dbg调试功能,请问这个是干嘛用的? 各位有没有什么PHP的好书推荐? php字符变量 异或 疑问,请解决 filesize不能支持远程文件那么该如何知道远程文件的大小? 做这么一个网站要多少软件开发费?
这样还是不行
/<sohu.[^<]*<\/sohu/i
这样才行不知为什么?
$ttt =<<< eof
test
<sohu_cms_include:learning_articlefrag1><p align=center><a href=http://2004.sports.sohu.com/ target=_blank><font color=red><b>搜狐奥运王者归来,七种武器谁与争锋</b></font></a> <a href=http://2004.sports.sohu.com/ target=_blank><img src="http://photo.sohu.com/20040809/Img221437781.gif" height="10" border=0></a></p> </sohu_cms_include>
eof;
echo $opf = preg_replace("/<sohu[.\n]*<\/sohu/i","",$ttt);
结果还是老样子.
$ttt = < < < eof
test
<sohu_cms_include:learning_articlefrag1>
<p align=center >
<a href=http://2004.sports.sohu.com/ target=_blank > <font color=red > <b >搜狐奥运王者归来,七种武器谁与争锋 </b > </font > </a > <a href=http://2004.sports.sohu.com/ target=_blank > <img src= "http://photo.sohu.com/20040809/Img221437781.gif " height= "10 " border=0 > </a > </p >
</sohu_cms_include>
eof;
echo $opf = preg_replace( "/ <sohu[.\n]* <\/sohu/i ", " ",$ttt);
里面包含\n的情况所以要[.\n],但就是不行!
在PHP中可以通过/s来使它匹配
echo $opf = preg_replace("/<sohu(.*)<\/sohu/s","",$ttt);