diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt index f4cf4b6029..2fd52b69f3 100644 --- a/docs/topics/http/urls.txt +++ b/docs/topics/http/urls.txt @@ -320,10 +320,10 @@ prefix is used repeatedly. For example, consider this URLconf:: from . import views urlpatterns = [ - url(r'^(?P\w+)-(?P\w+)/history/$', views.history), - url(r'^(?P\w+)-(?P\w+)/edit/$', views.edit), - url(r'^(?P\w+)-(?P\w+)/discuss/$', views.discuss), - url(r'^(?P\w+)-(?P\w+)/permissions/$', views.permissions), + url(r'^(?P[\w-]+)-(?P\w+)/history/$', views.history), + url(r'^(?P[\w-]+)-(?P\w+)/edit/$', views.edit), + url(r'^(?P[\w-]+)-(?P\w+)/discuss/$', views.discuss), + url(r'^(?P[\w-]+)-(?P\w+)/permissions/$', views.permissions), ] We can improve this by stating the common path prefix only once and grouping @@ -333,7 +333,7 @@ the suffixes that differ:: from . import views urlpatterns = [ - url(r'^(?P\w+)-(?P\w+)/', include([ + url(r'^(?P[\w-]+)-(?P\w+)/', include([ url(r'^history/$', views.history), url(r'^edit/$', views.edit), url(r'^discuss/$', views.discuss),