compete.withcode.uk

C# Competition

Challenge: Validation #5 Pattern check 1

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:
inputreturn valueexplanation
00/00/0000true2 numerical digits then a forward slash, then 2 numerical digits then a forward slash, followed by 4 numerical digits
-1/00/0000falseall digits must be numerical (minus signs are not allowed)
123/00/0000falsetoo many digits for the day
1/00/0000falsetoo few digits for the day
##/##/####falsedigits are not numerical
27\11\2021falsethe separator must be a forward slash
-00/00/0000-falsethere 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; }

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