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

12 lines
452 B
Markdown

# Find the time as hh:mm or hh-mm
The time can be in the format `hours:minutes` or `hours-minutes`. Both hours and minutes have 2 digits: `09:00` or `21-30`.
Write a regexp to find time:
```js
let reg = /your regexp/g;
alert( "Breakfast at 09:00. Dinner at 21-30".match(reg) ); // 09:00, 21-30
```
P.S. In this task we assume that the time is always correct, there's no need to filter out bad strings like "45:67". Later we'll deal with that too.