suppose I have a string containing substrings
# the substrings and the whole string surrounded by parenthesis
string = '((substring1)(substring2))'
I want to get both substring1 & substring2 using regex, but I'm having a problem :(
This is what I have now:
match = re.search('(\(.*\))', string)
print match.groups()
The problem is, the result shows:
('(substring1)(substring2)', )
It seems like the regex matches only the first opening parenthesis and the last closing parenthesis..
In other words, the matching regex is like..
( match..... )
instead of
( (match1)(match2) )
How do I make the regex catch the INNER parenthesis??
Thanks