I’m in a rush so I don’t have time to review regex rules.
I would like to know how do I check if a string is in this format "12:30-14:30", where
- the start time has to be before the end time.
- the minute section has to be ":00" or ":30".
- the hour section is between "08:" and "20:".
Any help will be greatly appreciated! Thank you.
>Solution :
The regex answer is:
^((0[8-9]|1[0-9]|20):[03]0)-((0[8-9]|1[0-9]|20):[03]0)$
Note that this does not ensure that the start time is before the end time, you would need additional Java code to do that.