开发者

Need help with regular expression

开发者 https://www.devze.com 2023-01-25 12:06 出处:网络
I am using Django for my application and needed to do a pattern matching Pattern to be matched: users/?q=john

I am using Django for my application and needed to do a pattern matching

Pattern to be matched: users/?q=john Regular expression : '^users/\?q\=(?P[\w]+)[/]?$'

like this in urls.py

url(r'^users/\?q\=(?P[\w]+)[/]?$', user_handler, {'emitter_format' : 'json'})

However it's no开发者_Go百科t matching the URL, any pointers would be helpful.

Thanks


In CGI, everything after ? is put into request.GET and does not even get to url matching - take a look here:

  • http://docs.djangoproject.com/en/dev/ref/request-response/

In your handler (user_handler), you can use:

request.GET['q']

to get john from the above sample URL.

0

精彩评论

暂无评论...
验证码 换一张
取 消