On /^\d{2}(:\d{2}){2}$/
:
/.../
delimiters the regex expression.
^
matches the start of the line, if on multi line mode, or the beginning of the string otherwise.
\d
matches one digit
{2}
states that the preceding statement \d
must match 2 times.
(...)
delimiters a capture group. It group things together as the usual math parenthesis concept and also allow you to you refer to them latter using \i
, where i
is the index of the group. Example, (a)(b), a
is the group 1 and b
is the group 2.
\d{2}
just explained on the steps 3
and 4
.
{2}
the same as on the step 4
, but here the preceding is the capture group (:\d{2})
, which must repeat also 2 times.
$
matches the end of the line, if on multi line mode, or the end of the string otherwise.
If the multi line mode is enabled, your expression matches only things like:
22:33:44
02:33:44
But not as
22:33:44 d
d 22:33:44
f 02:33:44 f
If multi line is not enabled, your expression only matches a string containing a valid expression as:
22:33:44
But nothing, on a string with two valid lines:
22:33:44
02:33:44
This is a link for live testing: https://regex101.com/r/cdSdt4/1