- Task
- The date consists of 2-digits each for month and day and between
either 2 or 4 digits for the year. The values can be separated by either a
period, a slash, or a hyphen.
-
Example
- 05-12-2000 or 05.12.2000 or 05/12/2000
- Solution
-
[01][0-9][-./][0-3][0-9][-./][0-9]{2,4}
- Explanation
-
[01][0-9]
The first numerical expression, the month, consists of two
digits. The first digit can be 0 or 1. The second digit can be any digit
between 0 and 9.
-
[-./]
Either a dash, a period, or a slash separates the month from the
day.
-
[0-3][0-9]
The second numerical expression, for the day of the month,
consists of two digits. The first digit can be 0, 1, 2 or 3. The second digit
can be any digit between 0 and 9.
-
[-./]
Either a dash, a period or a slash separates the month from the
year.
-
[0-9]{2,4}
The third numerical expression, for the year, consist of 2 to 4
digits in length and can include any digit from 0 to 9.