Regular Expressions 101

Community Patterns

Match time HH:MM:SS or MM:SS similar to YT chapters

0

Regular Expression
ECMAScript (JavaScript)

/
(^(?:[01]\d|2[0-3]|[0-59]):[0-5]\d:[0-5]\d)|(^(?:[0-5]\d|2[123]|[0-59]):[0-5]\d)
/
gm

Description

Used in JS context to extract time from string metadata aka YouTube chapters. Trailing text and chars are ignored for each new line.

Submitted by JVE - a year ago (Last modified a year ago)