I use a regular expression module for python, re.
I need to match something inside '(' ')' on these two phrases, but "not so greedy." Like this:
show the (name) of the (person)
calc the sqrt of (+ (* (2 4) 3))
The result should be returned from phrase 1:
name
person
The result should return from phrase 2:
+ (* (2 4) 3)
The problem is that, to match the first sentence, I used '\(.*?\)'
This, in the second sentence, just fits + (* (2 4)
And using the '\(.*\)'second phrase for the correct installation, the first phrase is suitable(name) of the (person)
Does regular expression work on both phrases correctly?
source
share