Objective
Create a Python program that checks the format of a date and extracts its parts using groups in a regular expression.
Instructions
- Read a date.
- Check with
re.fullmatch(r"(\d{2})/(\d{2})/(\d{4})", date)that it has the formatDD/MM/YYYY, with two digits for the day and the month. The parentheses form three groups. - If it matches, get the groups with
.groups()and showDay D, month M, year Y. - If it does not match, show
Invalid format. Only the format is checked, not that the date exists in the calendar.
13/11/2026
Day 13, month 11, year 2026
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise