regular expression for nested parentheses

Noah Hoffman noah.hoffman at gmail.com
Sun Dec 9 16:53:58 EST 2007


On Dec 9, 1:41 pm, John Machin <sjmac... at lexicon.net> wrote:

> A pattern that can validly be described as a "regular expression"
> cannot count and thus can't match balanced parentheses. Some "RE"
> engines provide a method of tagging a sub-pattern so that a match must
> include balanced () (or [] or {}); Python's doesn't.

Okay, thanks for the clarification. So recursion is not possible using
python regular expressions?

> Ummm ... even if Python's re engine did do what you want, wouldn't you
> need flags=re.VERBOSE in there?

Ah, thanks for letting me know about that flag; but removing
whitespace as I did with the no_ws lambda expression should also work,
no?



More information about the Python-list mailing list