I am new to Python and Regex. I was checking some tutorial regarding Regex and as per my understanding, all the codes below should have given me same output but I am not. Can someone please explain why I am not getting it.
In this example I am trying to find Batman or Batwoman in the paragraph.
import re
BatRegex = re.compile(r'Batman|Batwoman')
mo = BatRegex.findall('The adventures of Batman and Batwoman')
print(mo)
['Batman', 'Batwoman']
BatRegex = re.compile(r'Bat(man|woman)')
mo = BatRegex.findall('The adventures of Batman and Batwoman')
print(mo)
['man', 'woman']
BatRegex = re.compile(r'Bat(wo)?man')
mo = BatRegex.findall('The adventures of Batman and Batwoman')
print(mo)
['', 'wo']