求助一个正则表达式的问题 我想写一个正则表达式,{protect}{aa}{/protect}{aa}只替换未受{protect}保护的{aa}元素为abc 可以实现吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php$str='{protect}{aa}{/ptotect}{aa}';echo preg_replace("/(?<!{protect})\s*{aa}\s*(?!{\/protect})/",'111',$str);?> $str = <<<template{protect}{aa}{/protect}{aa} template;$str = preg_replace("/\{protect\}(.*)\{\/protect\}/iseu",'str_replace("{aa}","abc","\\0")',$str);echo $str; 不知道是不是LZ的意思 $a = '{aa}{protect} {aa} {/protect} {aa}{protect} {aa} {/protect} {aa}'; echo preg_replace('/({\/protect}[^\/{}]*|^[^\/{}]*){aa}([^\/{}]*{protect}|[^\/{}]*$)/is','${1}123$2',$a); $str = <<<template{protect}{aa} {aa}{/protect}{aa} {aa}template;echo preg_replace("#(\{protect\}.*\{\/protect\}|\{aa\})#ise",'preg_replace("#^{aa}$#","abc","\\0")',$str); 有规律就可以吧<?php$str='{aa} {protect} {aa} {/protect} {aa} ';$reg='/\{aa\}(?![^{]*\{\/protect\})/iU';$str = preg_replace($reg, 'abc', $str);echo $str;?> 学习PHP遇到瓶颈,如何继续? php使用freetds访问mssql的中文字符问题 怎样解决网页乱码的问题,急,在线等,谢谢 诚聘网站PHP工程师 修改一段代码,高手指教了 表单中用到单选按钮组,php语言怎么获取他的值啊 to:xuzuning(唠叨)等各位朋友,关于24日发的问题“文件用copy函数上传的问题,高分请教!请帮助我完成结贴的愿望!” 文件上传问题 mysql中,option是保留字段么? 奇怪的中文乱码问题 关于PHP搜索 最近学手机网页,有些问题想问问,用xhtml好还是wml好?
<?php
$str='{protect}
{aa}
{/ptotect}
{aa}';
echo preg_replace("/(?<!{protect})\s*{aa}\s*(?!{\/protect})/",'111',$str);
?>
{protect}
{aa}
{/protect}
{aa}
template;
$str = preg_replace("/\{protect\}(.*)\{\/protect\}/iseu",'str_replace("{aa}","abc","\\0")',$str);
echo $str;
{aa}
{/protect}
{aa}{protect}
{aa}
{/protect}
{aa}';
echo preg_replace('/({\/protect}[^\/{}]*|^[^\/{}]*){aa}([^\/{}]*{protect}|[^\/{}]*$)/is','${1}123$2',$a);
$str = <<<template
{protect}
{aa} {aa}
{/protect}
{aa} {aa}
template;echo preg_replace("#(\{protect\}.*\{\/protect\}|\{aa\})#ise",'preg_replace("#^{aa}$#","abc","\\0")',$str);
<?php
$str='
{aa}
{protect}
{aa}
{/protect}
{aa}
';
$reg='/\{aa\}(?![^{]*\{\/protect\})/iU';
$str = preg_replace($reg, 'abc', $str);
echo $str;
?>