当前位置:首页 - 建站教程 - php教程 - 正则表达式匹配最外层大括号里面的内容

正则表达式匹配最外层大括号里面的内容

时间:2019-02-10来源:帝国模板网 作者:帝国模板网 文章热度:
点评:匹配最外层大括号的内容
$strs=<<<string
female{{initiator}
www.sfk8.com
updated {person}&rsquo;s role to {role}}
string;
$params="/(?<=\{
...配最外层大括号的内容

$strs=<<<string
feMAle{{initiator}
www.sfk8.com
updated {person}’s role to {role}}
string;
$pARams="/(?<=\{).*(?=\})/is";
preg_mATCh($params,$strs,$matches);
print_r($matches);

最外层正则表达式:
(?<=\{).*(?=\})

最内层正则表达式:

{[^{}]+}

帝国cms模板网站长经过测试
相关php教程
最新php教程