I'm using python regular expression module, re
.
I need to match anything inside '(' ')' on this two phrases, but "not so greedy". Like this:
show the (name) of the (person)
calc the sqrt of (+ (* (2 4) 3))
The result should return, from phrase 1:
name
person
The result should return from phrase 2:
+ (* (2 4) 3)
The problem is that, to fit first phrase, I used '\(.*?\)'
This, on second phrase, just fits + (* (2 4)
And using '\(.*\)'
to fit second phrase correctly, on first phrase fits (name) of the (person)
What regex work on both phrases correctly?