用正则表达式匹配非括号内的数据?

用正则匹配括号内的数据,这个较容易实现,但是匹配括号外的数据,貌似就比较困难了.例如:"{controller}/cc/{action}/{id}"我…
关注者
13
被浏览
10,442
登录后你可以
不限量看优质回答私信答主深度交流精彩内容一键收藏

PHP

$str = '{controller}}/cc/{action}/{id}';
preg_match_all('/{.*}(.*){.*}(.*){.*}/U', $str, $matches);
var_dump($matches);

$matches[1] 为 }/cc

$matches[2] 为 /