title: Django REST framework url regex patterns not being matched
body: <p>I am writing a RESTful API as an application for a django project. 
  I have two end points in my application (with urls imported into the main project's urls.py), which are defined as shown below below:</p>
  
  <h2>testrest/urls.py</h2>
  
  <pre><code>from django.conf.urls import url
  
  from . import views
  
  urlpatterns = [
      url(r'prices/(?P&lt;ticker&gt;[X]{1}[A-Z0-9]{3}:[A-Z0-9]{1}[A-Z09.-]{1,4})/?P&lt;resolution&gt;([0-9]{0,3})/$', views.historyPrices, name='prices'),
      url(r'chart/?P&lt;name&gt;([a-zA-Z0-9_\.-]{8,12})/$s', views.chart, name='pchart'),
  ]
  </code></pre>
  
  <h2>testrest/views.py</h2>
  
  <pre><code>from rest_framework import status
  from rest_framework.decorators import api_view
  from rest_framework.response import Response
  
  
  
  # Create your views here.
  @api_view(['GET'])
  def historyPrices(request, ticker, resolution=1):
      if request.method == 'GET':
          try:
              # do something
              return Response({'foo': 'foobar'})
  
          except Exception as e:
              print ('Error: {0}'.format(e))
              return Response(status = status.HTTP_500_INTERNAL_SERVER_ERROR)     
      else:
          return Response(status = status.HTTP_405_METHOD_NOT_ALLOWED)
  
  
  
  @api_view(['GET', 'POST', 'PUT', 'DELETE'])
  def chart(request, name=None):
      if request.method == 'GET':     
          if (name is not None):      
              try:
                  # do something
              except Exception as e:
                  print('Error:',e)
                  return Response(status = status.HTTP_404_NOT_FOUND)         
  
              return Response({'foo': 'bar')
          else:
              return Response(status = status.HTTP_400_BAD_REQUEST)
  
  
      elif request.method == 'POST':
          data = request.data
          # print(data)
  
          try:
              # do something
              return Response(status = status.HTTP_201_CREATED)       
  
          except Exception as ex:
              print('Unhandled exception: {0}'.format(e))
              return Response(status = status.HTTP_500_INTERNAL_SERVER_ERROR)
  
  
      elif request.method == 'PUT':
          print('Called with PUT')
          return Response(status=status.HTTP_501_NOT_IMPLEMENTED)
  
      elif request.method == 'DELETE':
          print('Called with DELETE')
          return Response(status=status.HTTP_501_NOT_IMPLEMENTED)
  
      else:
          return Response(status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p>I want to be able to call using the following urls (all of those shown below, return a 404 not found error:</p>
  
  <pre><code>curl http://127.0.0.1:8000/testrest/prices/XNAS:GOOG      (404)
  curl http://127.0.0.1:8000/testrest/prices/XNAS:GOOG/     (404)
  curl http://127.0.0.1:8000/testrest/prices/XNAS:GOOG/3    (404)
  curl http://127.0.0.1:8000/testrest/prices/XNAS:GOOG/3/   (404)
  
  curl http://127.0.0.1:8000/testrest/prices?ticker=XNAS:GOOG      (404)
  curl http://127.0.0.1:8000/testrest/prices/?ticker=XNAS:GOOG&amp;resolution=3    (404)
  curl http://127.0.0.1:8000/testrest/prices?ticker=XNAS:GOOG&amp;resolution=3/   (404)
  </code></pre>
  
  <p>I now try to load a manually created chart (xyz) from the server:</p>
  
  <pre><code>curl http://127.0.0.1:8000/testrest/chart/xyz                 (404)
  curl http://127.0.0.1:8000/testrest/chart/xyz/                (404)
  curl http://127.0.0.1:8000/testrest/chart?name=xyz            (404)
  </code></pre>
  
  <p>I then try to POST (create) a new chart on the server:</p>
  
  <pre><code>curl -H "Content-Type: application/json" -X POST -d '{/* data */}' http://127.0.0.1:8000/testrest/chart     (404)
  </code></pre>
  
  <p>Why are the patterns not matching?</p>