I've seen a few threads on this, and have tried the solutions presented in them, but I can't seem to fix this. I have a regular expression that checks for two dates in mm/dd/yyyy , mm/dd/yyyy
format. There can be any number of spaces in between. My expression works on http://regexr.com/, but when I run the code in VS the regex check is always false. Any help would be greatly appreciated!
var reg = new Regex(@"\d{1,2}\/\d{1,2}\/\d{1,4}[ ]{0,}\,[ ]{0,}\d{1,2}\/\d{1,2}\/\d{1,4}");
Console.WriteLine("Please enter two dates in dd/mm/yyyy format seperated by a comma");
string datesIn = Console.ReadLine();
while (reg.IsMatch(datesIn) != true);
{
Console.WriteLine("Sorry, please make sure to enter your dates in dd/mm/yyyy format seperated by a comma.");
datesIn.Replace(datesIn, Console.ReadLine());
}
String[] dates = datesIn.Split(',');
foreach (var date in dates)
Console.WriteLine(date.Trim());
Console.ReadLine();