On 5/7/2009 4:51 PM Rajanikanth Jammalamadaka said...
Hi
I have a text file as follows:
testName = (
someParam = value1
anotherParam = (value2, value3)
)
how do I write a regular expression to get all the contents of the
file which are between the first and last parentheses.
In this case, I want:
someParam = value1
anotherParam = (value2, value3)
Thanks,
It's not a regex nor probably what you want, but I'd start with...
>>> filetext = '''testName = (
... someParam = value1
... anotherParam = (value2, value3)
... )'''
>>>
>>> print filetext.split("(",1)[-1].rsplit(")",1)[0]
someParam = value1
anotherParam = (value2, value3)
>>>
Emile
--
http://mail.python.org/mailman/listinfo/python-list