For the following code:
t1 = 'tyler vs ryan'
p1 = re.compile('(.*?) vs (.*?)')
print p1.findall(t1)
the output is:
[('tyler', '')]
but I would've expected this:
[('tyler', 'ryan')]
I have found that if I add a delimiter I can get it to work:
t2 = 'tyler vs ryan!' # Notice the exclamation mark
p2 = re.compile('(.*?) vs (.*?)!') # Notice the exclamation mark
print p2.findall(t2)
outputs:
[('tyler', 'ryan')]
Is there a way I can get my matches without having a custom delimiter?
No. Try this
gives:
$ - Matches the end of the string or just before the newline at the end of the string, and in MULTILINE mode also matches before a newline.