For example, I have a string like '(10 + 20) / (10 + 20)'
.
And now I want to match (10 + 20)
. So I write a script like this:
text = '(10 + 20) / (10 + 20)'
test1 = re.findall(r'(.*)', text)
test2 = re.findall(r'(.+?)', text)
for i in test1:
print(i, end='')
else:
print()
for i in test2:
print(i, end='')
else:
print()
And the output is this:
(10 + 20) / (10 + 20)
(10 + 20) / (10 + 20)
I don't understand, doesn't .+?
not greedy?