title: Regular expression for matching time in military (24 hour) format
body: <p>I would like a JavaScript regular expression that will match time using the 24 hour clock, where the time is given with or without the colon.</p>
  
  <p>For example, I would like to match time in the following formats:</p>
  
  <ul>
  <li><code>0800</code></li>
  <li><code>23:45</code></li>
  <li><code>2345</code></li>
  </ul>
  
  <p>but that would not match invalid times such as</p>
  
  <ul>
  <li><code>34:68</code></li>
  <li><code>5672</code></li>
  </ul>