请问怎样用正则表达式把{=yu}转换成<?=$yu?> $s = "{=yu}";echo preg_replace("/\{=yu\}/",'<?=$yu?>',$s); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 哎呀,"yu"是不定的,还有{=hh},{=yy}什么的,谢谢大哥了 preg_replace("/\{=(\w+)\}/",'<?=$\\1?>',$s); var strdata = '{=yu}';var newstr;newstr = strdata.replace(/{=/g, "<?=$");newstr = strdata.replace(/}/g, "?>"); 封个js脚本函数function replaceStr(strdata){var newstr;newstr = strdata.replace(/{=/g, "<?=$");newstr = strdata.replace(/}/g, "?>");return newstr;} 不用js直接用php进行两次替换就可以了:$str=preg_replace("/{=/g","<?=$",$str);$str=preg_replace("/}/g","?>",$str); 不过这样肯定是不太可能的,首先如果用户的一个句话中有一个"sagasgsa}"他就会把}换成?>,替换不确定,所以请高手发言 mysql查询耗cpu时间,帮我看看怎么优化这个mysql结构 关于oAuth认证的参数的疑问 更改数组名问题 分享----避免无端的 php 站的被人入侵。。。。。。 全选删除代码怎么写 【急死我了】为何phpexcel在win2003下就是运行不正常呢! 关于循环分组的问题 请教zend studio 调试问题 日历价格表? mysql超难问题 为什么我服务器上的fsockopen函数不能用? 怎么设置可以让php不报任何错误!
var newstr;
newstr = strdata.replace(/{=/g, "<?=$");
newstr = strdata.replace(/}/g, "?>");
function replaceStr(strdata)
{
var newstr;
newstr = strdata.replace(/{=/g, "<?=$");
newstr = strdata.replace(/}/g, "?>");
return newstr;
}
$str=preg_replace("/{=/g","<?=$",$str);
$str=preg_replace("/}/g","?>",$str);