Regular expressions · 13 / 15 Exercise Medium

Date with groups

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 format DD/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 show Day 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.
Input
13/11/2026
Output
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