How do you match 12 hour time hh:mm in a regex?

前端 未结 11 1012
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 01:48

How could you match 12 hour time in a regex-- in other words match 12:30 but not 14:74? Thanks!

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 02:36

    I believe the above fail in at least one way, particularly regarding strings such as "13:00" (Keith's matches "3:00" in that case).

    This one should handle that issue as well as the others brought up.

    ([01][0-2]|(?

提交回复
热议问题