Regex to match mm/dd/yyyy hh:mm:ss AM or PM

后端 未结 5 1313
逝去的感伤
逝去的感伤 2021-01-22 16:57

I have a program that creates information for a time stamp, the time stamp has to match the following format: MM/DD/YYYY HH:MM:SS AM or PM

For example:

5条回答
  •  青春惊慌失措
    2021-01-22 17:28

    Characters like / and :, and even letters can be added litterally. Try this:

    /[01][0-9]/[0-3][0-9]/[0-9]{4} [0-2]?[0-9]:[0-6]?[0-9]:[0-6]?[0-9] (AM|PM)/
    

提交回复
热议问题