title: reference length of regular expression group
body: <p>I'm trying to replace the digits at the end of a filename with hashes, for example <strong>image.0010001.tiff</strong> would become <strong>image.#######.tiff</strong></p>
  
  <p>Is it possible to do this using a single re.sub method?</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>re.sub('(\d+)(?=\.\w+$)', '#'*len('\g&lt;1&gt;'), 'image.0010001.tiff')
  </code></pre>