Question

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.

Was it helpful?

Solution

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top