Or use pyparsing, and do both at the same time (that spark example
looks like a lot of work!).
Download pyparsing at http://pyparsing.sourceforge.net.
-- Paul
from pyparsing import *
text = """
outer {
inner1 { ...1 }
inner2 { ...2 }
}
simple { ...3 }
null {}
Chris> I have a problem matching nested levels of {} ...
Regular expressions can't count, so you'd be better off sticking with
regexes to tokenize the source, then use a real parser to parse the tokens
it produces.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
> constructs like a**nn**n, with a={ and b=} in your case.
This should have been a**nb**n - an example would be aaabbb.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
Chris cdot.de> writes:
>
> is something like that possible?
No. Not with "pure" regexes. The reason is that the theory behind them doesn't
allow to detect syntactic
constructs like a**nn**n, with a={ and b=} in your case.
What you need is a "real" parser - usually one
uses regexes to split th
hello,
I have a problem matching nested levels of {}, example:
>>> import re
>>> text = """
outer {
inner1 { ... }
inner2 { ... }
}
simple { ... }
"""
>>> r = re.compile(r"""
( # OPTION1
.*? # begin