Which of the following lines of code will not show a match?

Which of the following lines of code will not show a match?
A. >>> re.match(‘ab*’, ‘a’)
B. >>> re.match(‘ab*’, ‘ab’)
C. >>> re.match(‘ab*’, ‘abb’)
D. >>> re.match(‘ab*’, ‘ba’)
 
Answer: d
Explanation: In the code shown above, ab* will match to ‘a’ or ‘ab’ or ‘a’ followed by any number of b’s. Hence the only line of code from the above options which does not result in a match is:
>>> re.match(‘ab*’, ‘ba’).
 

Tìm kiếm

Back
Top