No need for regex (using Python 3):
>>> from urllib.parse import parse_qs >>> query = parse_qs(str[1:]) >>> query {'q': ['salvia'], 'geocode': ['39.862712,-75.33958,10mi'], 'since_id': ['261042755432763393']} >>> query['q'] ['salvia'] >>> query['geocode'] ['39.862712,-75.33958,10mi']
Obviously str contains your input.
Since (according to your tag) you are using Python 2.7, I think you need to change the import statement to this:
from urlparse import parse_qs
and if you used Python before version 2.6, the import statement
from cgi import parse_qs
source share