Regular Expressions 101

Community Patterns

1...56789...902

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

~
^(?:2[0-3]|[01]\d|\d):[0-5]\d$
~
gm

Description

This matches times that fall within the normal range of times 00:00 - 23:59. It also allows for no leading zero for times like 6:24.

Submitted by quixrick - 8 years ago