David a écrit : > On 9/8/07, tool69 <[EMAIL PROTECTED]> 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. cheers, 6TooL9 -- http://mail.python.org/mailman/listinfo/python-list