According to Python's documentation for regular expression syntax for |
(or) operator: "...once A matches, B will not be tested further, even if it would produce a longer overall match. In other words, the '|' operator is never greedy."
I have tried this in my console (running Python 3.7.6):
import re
txt = 'tim is walking and tom is running'
pattern = 'tim|tom'
re.findall(pattern, txt)
and I get:
['tim', 'tom']
Why is the right side of |
still evaluated in this case?