高手帮忙看看这个正则该如何写才行? /<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的mysql数据库 循环插入数据的时候 有一个字段出现了重复的情况 要求是唯一的 怎么办 php操作word的问题 asp.net,jsp,php,哪个好找工作 base64_decode php的base64这个算法的加密与解密是怎么样的呢? zend 出错处理的问题 这些特殊的函数都是干什么用的? php无法删除mssql中记录 PHP命名空间问题 mysql limit出bug了 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);