应用正则表达式遇到问题,请帮忙 $txt = preg_replace( "/\[\/wav\]/", "[/player]", $txt ); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php$txt="[wav]http://www.xxx.com/1.mp3[/wav]";$txt = preg_replace( "/\wav/", "player", $txt );echo $txt;?> <?php$txt="[wav]http://www.xxx.com/1.mp3[/wav]";$txt = preg_replace( "/\wav/", "player", $txt );echo $txt;?> 这样写好一点:$txt = preg_replace( "/\wav]/", "player]", $txt ); 这样会更好更安全:<?php$txt="[wav]http://www.xxx.com/1.mp3[/wav]";$txt = preg_replace("/\[(\/)?wav]/gi", "[\\1player]", $txt);echo $txt;?> $txt = preg_replace("/\[(\/)?wav]/i", "[\\1player]", $txt);楼上多了一个g吧 :) 非常感谢上面几位的帮忙,谢谢!现在我又遇到些问题,就是这种形式的串:<!--Image http://fef.com/cfds.jpg--><a href='http://fef.com/cfds.jpg' target='_blank'><img src='http://fef.com/cfds.jpg' border='0' alt='用户发表的图象' onload='javascript:if(this.width>(screen.width*0.8-400)) this.width=(screen.width*0.8-400)'></a><!--End Image-->转换成这样的形式这个真是太难了!!大家看看呀! echo preg_replace("/^\[wav\](.+)\[\/wav\]/","[player]\\1[/player]","[wav]http://www.xxx.com/1.mp3[/wav]");$str="<!--Image http://fef.com/cfds.jpg--><a href='http://fef.com/cfds.jpg' target='_blank'><img src='http://fef.com/cfds.gif' border='0' alt='用户发表的图象' onload='javascript:if(this.width>(screen.width*0.8-400)) this.width=(screen.width*0.8-400)'></a><!--End Image-->";if(preg_match("/href=['|\"](.+)['|\"].+src=['|\"](.+)['|\"]/iU",$str,$pats)){echo "".$pats[1]."][IMG]".$pats[2]."[/IMG";} echo preg_replace("/^\[wav\](.+)\[\/wav\]/","[player]\\1[/player]","[wav]http://www.xxx.com/1.mp3[/wav]");$str="<!--Image http://fef.com/cfds.jpg--><a href='http://fef.com/cfds.jpg' target='_blank'><img src='http://fef.com/cfds.gif' border='0' alt='用户发表的图象' onload='javascript:if(this.width>(screen.width*0.8-400)) this.width=(screen.width*0.8-400)'></a><!--End Image-->";if(preg_match("/href=['|\"](.+)['|\"].+src=['|\"](.+)['|\"]/iU",$str,$pats)){echo "".$pats[1]."][IMG]".$pats[2]."[/IMG";} PHP写聊天室,即时通信或者在线客服有什么思路? 时间去掉年 高分求一个上传文件的php代码!谢谢!!! 关于类一个很奇怪的小问题~ 请各位帮忙解决~~~ 加速你的页面——数据压缩 为什么循环只执行了一次? 2K下PHP配置问题 php中可变变量问题 网站被恶意攻击 php curl 图片并保存 请教一个小问题 关于Session的问题,请各位支持支持!
$txt="[wav]http://www.xxx.com/1.mp3[/wav]";
$txt = preg_replace( "/\wav/", "player", $txt );
echo $txt;
?>
$txt="[wav]http://www.xxx.com/1.mp3[/wav]";
$txt = preg_replace( "/\wav/", "player", $txt );
echo $txt;
?>
$txt = preg_replace( "/\wav]/", "player]", $txt );
$txt="[wav]http://www.xxx.com/1.mp3[/wav]";
$txt = preg_replace("/\[(\/)?wav]/gi", "[\\1player]", $txt);
echo $txt;
?>
楼上多了一个g吧 :)
现在我又遇到些问题,就是这种形式的串:
<!--Image http://fef.com/cfds.jpg--><a href='http://fef.com/cfds.jpg' target='_blank'><img src='http://fef.com/cfds.jpg' border='0' alt='用户发表的图象' onload='javascript:if(this.width>(screen.width*0.8-400)) this.width=(screen.width*0.8-400)'></a><!--End Image-->转换成这样的形式这个真是太难了!!大家看看呀!
if(preg_match("/href=['|\"](.+)['|\"].+src=['|\"](.+)['|\"]/iU",$str,$pats))
{
echo "".$pats[1]."][IMG]".$pats[2]."[/IMG";
}
if(preg_match("/href=['|\"](.+)['|\"].+src=['|\"](.+)['|\"]/iU",$str,$pats))
{
echo "".$pats[1]."][IMG]".$pats[2]."[/IMG";
}