title: Python Regex to match time format works - why?
body: <p>I'm writing a function that needs to match hour/minute/seconds in order to allow the user to provide a time argument on the command line in a more convenient fashion than just specifying the number of seconds.</p>
  
  <p>The formats it needs to accept include:</p>
  
  <pre><code>hh:mm:ss
     mm:ss
        ss
  </code></pre>
  
  <p>I found a python regex that works at the following location: <a href="http://blog.yjl.im/2012/05/nargs-and-type-check-in-argparse-using.html" rel="nofollow">http://blog.yjl.im/2012/05/nargs-and-type-check-in-argparse-using.html</a></p>
  
  <p>The regex is: <code>'^(?:(?:(\d+):)?(\d+):)?(\d+)$'</code>.</p>
  
  <p>My question is: Why does it work? I've always thought that I was fairly good with regex, but I'm not able to fully understand this one, even with the aid of my cheatsheets.</p>
  
  <p>Can somebody explain?</p>