title: Regular expression for time of a day
body: <p>I am trying to create a regular expression for time of a particular day. It handles <code>7am</code> and <code>11:34pm</code> correctly. It should be able to identify the ill-formed times. Now I have tried writing a working regular expression for the problem.</p>
  
  <p><strong>Regular Expression</strong><code>^(([0]?[0-9])|([1][0-2]))(\:[00-59]{2})?(am|pm){1}\b</code></p>
  
  <p>The problem is that in antemeridiem, the hour part varies from <code>1</code>(or <code>01</code>) to <code>12</code> but in postmeridiem it varies from <code>0</code>(or <code>00</code>) to <code>12</code>. I am not able to deduce the regex for this situation. Kindly help.</p>