Community Patterns

Community Library Entry

1

Regular Expression
Created·2022-11-05 01:37
Flavor·PCRE2 (PHP)

/
^[1-9][0-2]*:[0-5][0-9]*[ ]*[am|pm]*$
/
gmi
Open regex in editor

Description

The get-time regex checks for the time format of a 12-hour clock, as follows: the hour is between 1 and 12, with no leading zero, followed by a colon, then minutes between 00 and 59, then an optional space, and then AM or PM, in upper or lower case

Submitted by Ahmed Ibrahim