found this datetime regular expression in RegExLib site -> http://regexlib.com/REDetails.aspx?regexp_id=361
string pattern = @"(((((0[13578])|([13578])|(1[02]))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(3[01])))|((([469])|(11))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(30)))|((02|2)[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9]))))[\-\/\s]?\d{4})(\s(((0[1-9])|([1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?";
var match = Regex.Match("test 123 11/30/2003 10:12:24 am", pattern, RegexOptions.IgnoreCase);
the datetime format i’m looking for is m/d/yyyy hh:mm:ss
the above looks for m/d/yyyy hh:mm am|pm
Two minutes of work using RegexBuddy gave me a solution of:
This matches
11/30/2003 10:12:24in your test expression. It also matches11/30/2003 23:12:24and11/30/2003 00:00:01