开发者

Need help with regular expression

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜