Pranav Garg
Pranav Garg

Reputation: 613

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 not matching the URL, any pointers would be helpful.

Thanks

Upvotes: 0

Views: 87

Answers (1)

icyrock.com
icyrock.com

Reputation: 28618

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

In your handler (user_handler), you can use:

request.GET['q']

to get john from the above sample URL.

Upvotes: 1

Related Questions