Regular Expressions 101

Community Patterns

123...6

date time validation

1

Regular Expression
.NET 7.0 (C#)

@"
^(((\d\d)(([0][13578]|[1][0]|[1][2])([0][1-9]|[1-2][0-9]|[3][0-1])|([0][469]|[1][1])([0][1-9]|[1-2][0-9]|[3][0])|([0][2])([0][1-9]|[1][0-9]|[2][0-8])))|([02468][048]|[13579][26])([0][2])([0][1-9]|[1-2][0-9]))-([0-1][0-9]|[2][0-3])_([0-5][0-9])_([0-5][0-9])$
"
gm

Description

Validation of the date of time, taking into account the high year in the format date.ToString("yyMMdd-hh_mm_ss").

Submitted by Oleksii Serikov (alex@neochrom.biz) - a year ago