P
poi
I found this regex on the web and it takes dates as MM/DD/YYYY. I need
it to take dates as YYYY-MM-DD but can't see how, can anyone point me in
the right direction?
System.Text.RegularExpressions.Match dateMatch;
System.Text.RegularExpressions.Regex dateTest =
new Regex(
@"^((((((0?[13578])|(1[0-2]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|
(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((
0?[1-9])|([1-2][0-9]))))[\-\/\s]?\d{2}(([02468][048])|([13579][26])))|((
(((0?[13578])|(1[0-2]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[
469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9
])|(1[0-9])|(2[0-8]))))[\-\/\s]?\d{2}(([02468][1235679])|([13579][013457
89]))))(\s(((0?[1-9])|(1[0-2]))\[0-5][0-9])((\s)|(\[0-5][0-9])\s))([
AM|PM|am|pm]{2,2})))?$" );
dateMatch = dateTest.Match( this.txtDateofLoss.Text.Trim() );
if ( dateMatch.Success == false )
{}
it to take dates as YYYY-MM-DD but can't see how, can anyone point me in
the right direction?
System.Text.RegularExpressions.Match dateMatch;
System.Text.RegularExpressions.Regex dateTest =
new Regex(
@"^((((((0?[13578])|(1[0-2]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|
(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((
0?[1-9])|([1-2][0-9]))))[\-\/\s]?\d{2}(([02468][048])|([13579][26])))|((
(((0?[13578])|(1[0-2]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[
469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9
])|(1[0-9])|(2[0-8]))))[\-\/\s]?\d{2}(([02468][1235679])|([13579][013457
89]))))(\s(((0?[1-9])|(1[0-2]))\[0-5][0-9])((\s)|(\[0-5][0-9])\s))([
AM|PM|am|pm]{2,2})))?$" );
dateMatch = dateTest.Match( this.txtDateofLoss.Text.Trim() );
if ( dateMatch.Success == false )
{}