Regular expression for date time format “MM/DD/YY HH:mm:ss AM/PM” in asp.net regular expression validator

前端 未结 7 936
粉色の甜心
粉色の甜心 2020-12-19 15:54

Can anyone tell me the regular expression format for \"MM/DD/YY HH:mm:ss AM/PM\" to use it in a regular expression validator, in asp.net 2.0

相关标签:
7条回答
  • 2020-12-19 16:55

    This worked for me

    ^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$
    

    Source of regex

    0 讨论(0)
提交回复
热议问题