Parsing nested constructs

tool69 kib2 at
Sun Sep 9 00:03:47 CEST 2007

David a écrit :
> On 9/8/07, tool69 <kib2 at> wrote:
>> Hi,
>> I need to parse some source with nested parenthesis, like this :
> If this is exactly how your data looks, then how about a loop which
> searches for "{item" and the following "}"? You can use the "find"
> string method for that.
> Otherwise, if the items don't look exactly like "{item", but the
> formatting is otherwise exactly the same as above, then look for lines
> that have both "{" and "}" on them, then get the string between them.
> Otherwise, if { and } and the item aren't always on the same line,
> then go through the string character by character, keep track of when
> you encounter "{" and "}". When you encounter a "}" and there was a
> "{" before (ie, not a "}"), then get the string between the "{" and
> the "}"
Hi David,

thanks for answering, I will choose the last one as my strings are not 
on the same line and may contain a lot of stuff inside.



More information about the Python-list mailing list