I need a regex, which matches a single time value as well as lists of time values in the format hhmm[, hhmm] like for example:
“1245” or “0056, 1034,2355”
I am not so good with regex.. I thought this would do it:
(([0-1][0-9])|(2[0-3]))[0-5][0-9](,[ \t]*(([0-1][0-9])|(2[0-3]))[0-5][0-9])*
single time values are validated correctly, but if I try lists of times, every number behind the comma is accepted. It matches also “1235, 4711”.
Can someone give me a hint what i am doing wrong?
Thanks in advance!
1 Answer