Re: Regex for nested {}

2005-07-28 Thread Paul McGuire
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 {}

Re: Regex for nested {}

2005-07-28 Thread skip
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

Re: Regex for nested {}

2005-07-28 Thread Diez B.Roggisch
> 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

Re: Regex for nested {}

2005-07-28 Thread Diez B.Roggisch
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

Regex for nested {}

2005-07-28 Thread Chris
hello, I have a problem matching nested levels of {}, example: >>> import re >>> text = """ outer { inner1 { ... } inner2 { ... } } simple { ... } """ >>> r = re.compile(r""" ( # OPTION1 .*? # begin