title: How to parse time factor regular expression
body: <p>I am using the regular expression <code>([1-9]|1[0-2]|0[1-9]):([0-5][0-9]) (AM|PM|am|pm)</code> for time factor. e.g. HH:MM pm. </p>
  
  <p>Now I have to use this regular expression.</p>
  
  <p>Sample code:</p>
  
  <pre><code>if(currentVal.match(/([1-9]|1[0-2]|0[1-9]):([0-5][0-9]) (AM|PM|am|pm)/g) != currentVal) {
      alert("Invalid time.");
  }                         
  
  var parts = currentVal.split(" ");
  
  
  var parts = currentVal.split(":");
  parts[0] = parseInt(parts[0]);
  parts[1] = parseInt(parts[1]);
  
  if(parts[0] == 12) {
      parts[0] = 0;
  }
  if(parts[1].toLowerCase() == 'pm') {
      parts[0] += 12;
  }
  </code></pre>
  
  <p>Here, my mistake is <code>parseInt(parts[1])</code>; because regular expression have ":" and "space" and  "(AM|PM|am|pm)" so it is not converting <code>parts[1]</code> in lower case. </p>
  
  <p>Can anyone help me to use this regular expression?</p>