Where is a mistake?

Report a typo

One of your friends has compiled a regexp pattern to match all days of the months in the following format: DD/MM/YYYY.
At first glance, the pattern looks fine. However, during matching, the output is always None. Can you spot the mistake?

Sample Input 1:

10/10/2000

Sample Output 1:

<re.Match object; span=(0, 10), match='10/10/2000'>
Write a program in Python 3
import re

string = input()
dates = re.compile('''^(0[1-9]|[12][0-9]|3[01]) # digits from 01 to 31
(/) # forward slash
(0[1-9]|1[012]) # digits from 01 to 12
(/) # forward slash
(19|20)\d\d$ # 19 or 20 with any two digits
''')
result = dates.match(string)
print(result)
___

Create a free account to access the full topic