Regular Expressions 101

Community Patterns

TimeFormatParser

2

Regular Expression
PCRE (PHP <7.3)

/
^(.*?)(H{1,2})((.*?)(M{1,2})((.*?)(S{1,2})(.*?)|.*)|.*)$
/
m

Description

This allows to the programer to match the time format groups, in a way that allow to discard some parts of the format. E.g. I have a format HhMmSs and i want to ignore the 'Ss' part from the format when I have no Seconds

Submitted by Fausto A. Guerrero - 9 years ago