4

I want my urls.py to capture a long url setting as such:

/get/<lowercase_string>/<integer>/<date>/<date>/

For instance: www.mysite.com/get/ams/221/12-23-2010/01-10-2011/, as you may see date is in month/day/year format.

As my regex knowledge is near to nothing, I will be grateful for you guidance. I will be capturing <lowercase_string>, <integer>, <date>, <date> parts at my view.

Thanks.

1 Answer 1

20
^get/([a-z]+)/(\d+)/(\d{2}-\d{2}-\d{4})/(\d{2}-\d{2}-\d{4})/

#to capture the values in variables:

^get/(?P<lowercase_string>[a-z]+)/(?P<integer>\d+)/(?P<date1>\d{2}-\d{2}-\d{4})/(?P<date2>\d{2}-\d{2}-\d{4})/
Sign up to request clarification or add additional context in comments.

2 Comments

@arielnmz It's okay.. just fyi: you can revert a vote by clicking again.
They have to edit the question first since it has been quite some time since I downvoted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.