Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(([1[:digit:]]{2})|([[:digit:]]{1}))([[:digit:]]{2})
/

Description

This expression converts any 3- or 4 digit timevalue to a value with colon between hours and minutes. So 345 is converted to 3:45 and 1500 is converted to 15:00

Submitted by Patrick Sinke - 9 years ago