Q:

I want to validate time like 6:30 or 11:54 AM but not UTC+6:30

I am currently using the pattern:
(0*[1-9]|1[0-9]|2[0-3]):([0-5][0-9]) *(AM|am|PM|pm)*

But this also validated 6:30 in "UTC+6:30"
I don't want it to validate any time after "UTC+" or "UTC-"

A:

@TesselatingHeckler's idea of using a negative lookbehind assertion is correct, however there is one important thing missing. You also need a word boundary anchor:
(?<!UTC[+-])\b(0*[1-9]|1[0-9]|2[0-3]):([0-5][0-9]) *([AP]M|[ap]m)?

Otherwise, UTC+11:00 would also match (because 1:00 is a valid match for this regex).
Another thing: Why should 00:30 not be a valid match? Wouldn't
(?<!UTC[+-])\b([01]?[0-9]|2[0-3]):([0-5][0-9]) *([AP]M|[ap]m)?

be better?

