title: Regular expression to validate time
body: <p>I am using the Regular Expression 
  <code>"(?:[0-1]?[0-9]|[2][1-4]):[0-5]?[0-9]\s?(?:AM|am|PM|pm)?"</code>  to validate time.</p>
  
  <pre><code>var Regexp = new RegExp("(?:[0-1]?[0-9]|[2][1-4]):[0-5]?[0-9]\s?(?:AM|am|PM|pm)?");
  if (Regexp.test(starttime)) {
      var match = Regexp.exec(starttime);
      if (match) {
          s = match[0];
      }
  }
  </code></pre>
  
  <p>My input is <code>"7:00 AM"</code>. But my <code>match[0]</code> returns only <code>"7.00"</code> . This does not return <code>AM</code> or <code>PM</code> . There also seems to be only one group. How do I get <strong>AM/PM</strong> with the group?</p>