en.javascript.info/9-regular-expressions/05-regexp-character-sets-and-ranges/2-find-time-2-formats/solution.md
2019-04-02 14:01:44 +03:00

344 B

Answer: pattern:\d\d[-:]\d\d.

let reg = /\d\d[-:]\d\d/g;
alert( "Breakfast at 09:00. Dinner at 21-30".match(reg) ); // 09:00, 21-30

Please note that the dash pattern:'-' has a special meaning in square brackets, but only between other characters, not when it's in the beginning or at the end, so we don't need to escape it.