Regular expression of Traditional Time Formats


Regular expressions and life hacks to monitor and monitor the time period in the DLP and SIEM system.

You want to validate times in various traditional time formats, such as hh:mm and hh:mm:ss in both 12-hour and 24-hour formats.

  • RegEx

Hours and minutes, 12-hour clock

^(1[0-2]|0?[1-9]):([0-5]?[0-9])( ?[AP]M)?$

Hours and minutes, 24-hour clock


Hours, minutes, and seconds, 12-hour clock

^(1[0-2]|0?[1-9]):([0-5]?[0-9]):([0-5]?[0-9])( ?[AP]M)?$

Hours, minutes, and seconds, 24-hour clock


Leave a Reply

Your email address will not be published.