title: Rebuild regex string based on match keywords in python
body: <p>Example regular expression</p>
  
  <pre><code>regex = re.compile('^page/(?P&lt;slug&gt;[-\w]+)/(?P&lt;page_id&gt;[0-9]+)/$')
  matches = regex.match('page/slug-name/5/')
  &gt;&gt; matches.groupdict()
  {'slug': 'slug-name', 'page_id': '5'}
  </code></pre>
  
  <p>Is there an easy way to pass a dict back to the regex to rebuild a string?</p>
  
  <p>i.e. <code>{'slug': 'new-slug', 'page_id': '6'}</code> would yield <code>page/new-slug/6/</code></p>