日期:2014-05-17 浏览次数:20643 次
$string = "some text (a(b(c)d)e) more text";
if(preg_match("/\((?>[^()]+|(?R))*\)/",$string,$matches))
{
echo "<pre>"; print_r($matches); echo "</pre>";
}
<?php
$string = 'some text <tag:cate name="a">a<tag:cate name="b">b<tag:cate>c</tag:cate>d</tag:cate>e</tag:cate> more text';
preg_match("/<tag:cate(?: name=\"\w+\")?>(?>\w+|(?R))*<\/tag:cate>/",$string,$matches) &&
print_r($matches);