This regex:
import re
string = 'I am a long string with many regexes matching'
pattern = '.*(?:with|regexes)'
print(re.findall(pattern, string))
returns
['I am a long string with many regexes']
How can I instead make it return:
['I am a long string with']
i.e. when both the short and long version of the regex is present, return the shorter string.