Regular Expressions 101

Community Patterns

Community Library Entry

3

Regular Expression
PCRE (PHP <7.3)

/
^(\d{1,2}[h])$|^(\d+[m])$|^((\d{1,2}[h])\s((([0]?|[1-5]{1})[0-9])[m]))$
/
i

Description

Match time duration in the following formats only: 1h 30m 59m 1h 33m 11h 2m

Submitted by Pooja Khorjuvekar - 9 years ago