title: How to extract the related fields for base, version and others from this url?
body: <p>I have a url</p>
  
  <pre><code>http://example.com/embed/comments/?base=default&amp;version=17f88c4&amp;f=fir&amp;t_i=article_25&amp;t_u=http%3A%2F%2Fwww.firstpost.com%2Fsports%2Fkotla-test-22.html%09&amp;t_e=Kotla%20Test20struggle&amp;t_d=Kotla%20Test20struggle&amp;t_t=Kotla%20Test20struggle&amp;s_o=default
  </code></pre>
  
  <p>The queries are
  base, version, f, t_i, t_u, t_e, t_d, t_t, s_o</p>
  
  <p>Constraints: </p>
  
  <ol>
  <li>base, version, f are necessary.</li>
  <li>Others t_i, t_u, t_e, t_d, t_d, s_o are optional i.e some may appear sometimes, sometimes not.</li>
  </ol>
  
  <p>I need to find the correct regular expression. Learned about them and came up with this</p>
  
  <pre><code>r'^embed/comments/?base=(\w+)&amp;version=(\w+)&amp;f=\w+&amp;t_i=\w+&amp;t_u=.+&amp;t_e=.+&amp;t_d=.+&amp;t_t=.+&amp;s_o=\w+'
  </code></pre>
  
  <p>I am using django, so in urls.py ,the above should match and it does. </p>
  
  <p>Q.0. How to extract the related fields for base, version and others? With the constraints what should be the regex modified to?</p>
  
  <p>For example to save forum , below regex is used. I searched for more than two hours but could not find what <code>?P&lt;forum&gt;</code> functionality is</p>
  
  <p>Q.1. What does <code>?P&lt;forum&gt;</code> mean?</p>
  
  <pre><code>r'^forum/(?P&lt;forum&gt;.+)/$'
  </code></pre>
  
  <p>P.S. I am a newbie to regex, please bear with me and explain in simpler terms. Thank you so much</p>