Choose the function whose output can be: <_sre.SRE_Match object; span=(4, 8), match=’aaaa’>.
A. >>> re.search(‘aaaa’, “alohaaaa”, 0)
B. >>> re.match(‘aaaa’, “alohaaaa”, 0)
C. >>> re.match(‘aaa’, “alohaaa”, 0)
D. >>> re.search(‘aaa’, “alohaaa”, 0)
Answer: a
Explanation: The output shown above is that of a search function, whose pattern is ‘aaaa’ and the string is that of 8 characters. The only option which matches all these criteria is:
>>> re.search(‘aaaa’, “alohaaaa”, 0)