32

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.

Cato Johnston
  • 44,131
  • 10
  • 39
  • 42

1 Answers1

89

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

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