nest expression & Pyparsing

http://pyparsing.wikispaces.com/

http://bbs.csdn.net/topics/330052586

C++ boost

"<([^<>]*?|(?R))*>"  

str = "<abcd<asdfasdf<sdfasdf>>sdaf>"


>>> from pyparsing import nestedExpr
>>> data2 = " <a < b <c>>d>"
>>> print nestedExpr("<", ">").parseString(data2).asList()
[['a', ['b', ['c']], 'd']]
>>> print nestedExpr("<", ">").parseString(data2).asList()[0]
['a', ['b', ['c']], 'd']
>>>

原文地址:https://www.cnblogs.com/yxwkf/p/5156523.html