Monday, July 28, 2014

regular expression for DateTime

Here is the regular expression for DateTime: yyyy-MM-dd HH:mm:ss

[1-9]\d{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])

0[1-9]|1[012] means if the first digit is 0, the second digit is [1-9], or if the first digit is 1 the second digit should be one of [012]

No comments:

Post a Comment