[^()]+|(?R))*)/",$string,$matches)) { echo ""; p"/> [^()]+|(?R))*)/",$string,$matches)) { echo ""; p">
嵌套正则写法
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> $string = "some text (a(b(c)d)e) more text"; if(preg_match("/\((?>[^()]+|(?R))*\)/",$string,$matches)) { echo "<pre class="brush:php;toolbar:false">"; print_r($matches); echo "
<?php $string = 'some text <tag:cate name="a">a<cate name="b">b<cate>c</cate>d</cate>e more text'; preg_match("/<cate name='\"\w+\")?'>(?>\w+|(?R))*/",$string,$matches) && print_r($matches); <div class="clear"> </div></cate>