Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(\d{2})\/(\d{2})\/(\d{4})(?: (?:(HOLIDAY)|(?:(?:(\d{2}:\d{2}) - (\d{2}:\d{2}))(?: (LUNCH) (\d{2}:\d{2}))?))$)
/
gm

Description

Parsing my work time sheet (doesn't validate times/dates). Options available:

12/17/2015 09:00 - 13:00 12/17/2015 09:00 - 17:00 LUNCH 00:30 12/17/2016 HOLIDAY

Submitted by Anthony N - 9 years ago