We help IT Professionals succeed at work.

Need regular expression for timeslot

Ashok Ash
Ashok Ash asked
on
The timeslot format is HH:MM AM/PM - HH:MM AM/PM (example -   08:00AM-10:00AM) Need regular expression to validate this
Comment
Watch Question

Top Expert 2016

Commented:
example -   08:00AM-10:00AM
Try
"\\d{2}:\\d{2}[AP]M-\\d{2}:\\d{2}[AP]M"

Open in new window

Top Expert 2016
Commented:
Hi,

pls try
(0[1-9]|1[0-2]):[0-5][0-9](A|P)M-(0[1-9]|1[0-2]):[0-5][0-9](A|P)M

Open in new window

REgards
Top Expert 2016

Commented:
A solution