Find the Dates
Imagine you're working as a data analyst for a company. You're tasked to go through loads of text data and extract valid date information. Dates could be in various formats,
dd/mm/yyyy
, dd-mm-yyyy
, or dd.mm.yyyy
. However, not every matching pattern is a valid date. You must ensure the month does not exceed 12, the day does not exceed 31, and the year is four digits long.Given a single line of input text, your program should output all valid dates. Each valid date should be printed on a new line.
Input | Output |
The contract was signed on 31/05/2023. A follow-up meeting was set for 13-06-2023. However, the client postponed it to 31.13.2023. They apologized on 28/02/2024. | 31/05/2023
13-06-2023
28/02/2024 |
Note: The program should disregard patterns such as 31.13.2023 since it is an invalid date (i.e., there is no 13th month).
Constraints
Time limit: 2.4 seconds
Memory limit: 512 MB
Output limit: 1 MB