Create a regular expression to match the 00:00:00 format for the duration (not the time)

Hi, I am using laravel and I want to check the creation of a regular expression that will allow you to use a specific format for the duration (and not the time, which can exceed the 24-hour format). so, for example, 124 hours 30 minutes and 24 seconds will be represented as 124: 30: 24. But the first value can be more than 1 character and number, the second value must be a colon, the third value must be 2 characters and a number, the fourth value must be a colon, and the fifth value should be 2 characters and numbers.

Any ideas how I can create a regex that will achieve this to insert into the next array?

$rules = array(
  'duration'          => 'required|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/'
);

Invalid examples:

alphacharacters e.g. qwerty
0:0:0
0:
0
1
30:211:211
30:2111:2111
a:d:d
asd

valid examples:

01:00:00
1:00:00
30:21:21
330:21:21
1330:21:21
11330:21:21
basically any amount of hours.
+4
1

:

^\d+:\d{2}:\d{2}$

: https://regex101.com/r/kO4xN2/2

\d - + - , ( )
{} - , ( )
^$ , , . .

+6

Source: https://habr.com/ru/post/1616892/


All Articles