0
我想开发一个基本的模板引擎,所以我必须使用preg_replace这么多。我有一个问题关于主题如下:Php preg_replace,正则表达式模式不匹配
$subject = "{%content%} %content%";
$pattern = '/matched_regex/';
$replace = 'OK';
echo preg_replace($pattern,$replace,$subject);
和输出必须是这样的:
{%content%} OK
换句话说
它将与%content%
正好匹配我应该怎么做正则表达式模式?
我已经试过这 $模式=“/ [^ {] \ S *(。?*)\ S *%[^}] /'; – 2015-03-02 21:31:32
and this $ pattern ='/{{0}?%\s*(.*?)\s*%}{0}/'; – 2015-03-02 21:35:09