Write a function which will check to see if a string contains characters matching the pattern of a date in the format dd/mm/yyyy
The numerical digits for date, month and year can be any number - you do not need to check if the values are valid (e.g. a month of 13 is still acceptable) but there must be exactly 2 characters for the day and month and exactly 4 characters for the year.
Test table:
input
return value
explanation
00/00/0000
true
2 numerical digits then a forward slash, then 2 numerical digits then a forward slash, followed by 4 numerical digits
-1/00/0000
false
all digits must be numerical (minus signs are not allowed)
123/00/0000
false
too many digits for the day
1/00/0000
false
too few digits for the day
##/##/####
false
digits are not numerical
27\11\2021
false
the separator must be a forward slash
-00/00/0000-
false
there should not be any invalid characters at the start or end of a valid date
Please note: The following code will be included above your code which you may find helpful:
using System.Text.RegularExpressions;
public static bool CheckDate(string date) {
/// TODO: implement pattern check for dd/mm/yyyy
return true;
}
Test
body
Previous attempts
You do not have any previously submitted code saved for this challenge
My Challenges
You do not have any C# challenges assigned for you to do