I'm interested how can be implemented recursive regexp matching in Python (I've not found any examples :( ). For example how would one write expression which matches "bracket balanced" string like "foo(bar(bar(foo)))(foo1)bar1"
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- PHP Recursively File Folder Scan Sorted by Modific
- Evil ctypes hack in python
You could use pyparsing
Running it yields:
You can't do it with a regexp. Python doesn't support recursive regexp
This is an old question, but for the people who come here through searches:
There's an alternative regex module for python that does support recursive patterns: https://pypi.python.org/pypi/regex
And it has a lot of more nice improvements on
re
.Unfortunately I don't think Python's regexps support recursive patterns.
You can probably parse it with something like pyparsing: http://pyparsing.wikispaces.com/