title: Representing version number as regular expression
body: <p>I need to represent version numbers as regular expressions. The broad definition is</p>
  
  <ol>
  <li>Consist only of numbers</li>
  <li>Allow any number of decimal points (but not consecutively)</li>
  <li>No limit on maximum number</li>
  </ol>
  
  <p>So <code>2.3.4.1,2.3,2,9999.9999.9999</code> are all valid whereas <code>2..,2.3.</code> is not.</p>
  
  <p>I wrote the following simple regex</p>
  
  <pre><code>'(\d+\.{0,1})+'
  </code></pre>
  
  <p>Using it in python with <a href="http://docs.python.org/library/re.html" rel="nofollow">re</a> module and searching in '2.6.31' gives</p>
  
  <pre><code>&gt;&gt;&gt; y = re.match(r'(\d+\.{0,1})+$','2.6.31')
  &gt;&gt;&gt; y.group(0)
  '2.6.31'
  &gt;&gt;&gt; y.group(1)
  '31'
  </code></pre>
  
  <p>But if I name the group, then the named group only has 31.</p>
  
  <p>Is my regex representation correct or can it be tuned/improved? It does not currently handle the <code>2.3.</code> case.</p>