My Django URLs not picking up dashes

允我心安 提交于 2019-12-20 10:26:21

问题


Im trying to work out a url that will match domain.com\about-us\ & domain.com\home\

I have a url regex:

^(?P<page>\w+)/$

but it won't match the url with the - in it.

I've tried

^(?P<page>\.)/$
^(?P<page>\*)/$

but nothing seems to work.


回答1:


Try: ^(?P<page>[-\w]+)/$

[-\w] will accept a-z 1-9 and dash



来源:https://stackoverflow.com/questions/531243/my-django-urls-not-picking-up-dashes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!