开发者

preg_replace with curly brackets

I'd like to replace the string "{{edit(3)}}" with "open3close" using pre开发者_运维百科g_replace


Escape { and } to \{ and \} in regex string


I'm sorry if you wasted your time, i found a valid solution.

preg_replace("/{{edit\((.*)\)}}/e","'open'.'\\\1'.'close'", $string);

input : {{edit(3)}}
output: open3close

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜