Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django url regex

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.

like image 863
Hellnar Avatar asked Nov 30 '22 10:11

Hellnar


1 Answers

^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})/
like image 125
Amarghosh Avatar answered Dec 10 '22 07:12

Amarghosh