Php preg_替换为花括号

Php preg_替换为花括号,php,preg-replace,Php,Preg Replace,我想使用regex string中的preg\u replace将字符串“{{edit(3)}}}”替换为“open3close”,替换为{/code>和}到{/code>和\},如果您浪费了时间,我很抱歉,我找到了一个有效的解决方案 preg_replace("/{{edit\((.*)\)}}/e","'open'.'\\\1'.'close'", $string); 输入:{edit(3)}} 输出:open3close 我猜是这样,但有些地方出了问题,你能给我举个例子吗?@TrustW

我想使用regex string中的
preg\u replace
将字符串
“{{edit(3)}}}”替换为
“open3close”
替换为
{/code>和
}
{/code>和
\}
,如果您浪费了时间,我很抱歉,我找到了一个有效的解决方案

preg_replace("/{{edit\((.*)\)}}/e","'open'.'\\\1'.'close'", $string);
输入:{edit(3)}}
输出:open3close


我猜是这样,但有些地方出了问题,你能给我举个例子吗?@TrustWeb,例如,
preg\u replace('/\{(.*?\}}}/',“open3close”,$text)