i have the following pattern : /^\/(?P<slug>.+)$/
that match : /url
.
My problem is that it also match /url/page
, how to ignore /
in this regex ?
The pattern should:
- Pattern match :
/url
- Pattern don't match :
/url/pag开发者_如何学编程e
Thanks in advance.
This should do it:
/^\/(?P<slug>[^\/]+)$/
[^\/]
matches every character that is not a slash (^
at the beginning of a character class negates the class). I recommend to have a look at http://www.regular-expressions.info/ to learn more about regular expressions.
精彩评论