title: Meaning of '^site_media/(?P<path>.*)$'
body: <pre><code># urls.py
  site_media = os.path.join(os.path.dirname(__file__), 'site_media'
  )
  
  urlpatterns = patterns('',
       (r'^site_media/(?P&lt;path&gt;.*)$', 'django.views.static.serve', 
                                       {'document_root': site_media}),
  )
  </code></pre>
  
  <p>I have problems to understand the meaning of the expression used in above statement.</p>
  
  <pre><code>'^site_media/(?P&lt;path&gt;.*)$'
  </code></pre>
  
  <p>What does it really mean?</p>
  
  <p>Thank you</p>
  
  <p>// ========== Updated based on comments  ==============</p>
  
  <p>Reference: <a href="https://docs.djangoproject.com/en/dev/topics/http/urls/" rel="nofollow">Name Groups</a>.</p>
  
  <p>In Python regular expressions, the syntax for named regular-expression 
  groups is <code>(?P&lt;name&gt;pattern)</code>, where <strong>name</strong> is the name of the group and 
  <strong>pattern</strong> is some pattern to match.</p>
  
  <p>Comparison:</p>
  
  <p><strong>Method 1></strong></p>
  
  <pre><code>(r'^articles/(?P&lt;year&gt;\d{4})/(?P&lt;month&gt;\d{2})/$', 'news.views.month_archive'),
  </code></pre>
  
  <p>A request to <code>/articles/2005/03/</code> would call the function </p>
  
  <p><code>news.views.month_archive(request, year='2005', month='03')</code>, </p>
  
  <p><strong>Method 2></strong></p>
  
  <pre><code>(r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'),
  </code></pre>
  
  <p>A request to <code>/articles/2005/03/</code> would call the function </p>
  
  <p><code>news.views.month_archive(request, '2005', '03')</code>.</p>