I have the following string from which I want to extract the q and geocode values.
?since_id=261042755432763393&q=salvia&geocode=39.862712%2C-75.33958%2C10mi
I’ve tried the following regular expression.
expr = re.compile('\[\=\](.*?)\[\&\]')
vals = expr.match(str)
However, vals is None. I’m also not sure how to find something before, say, q= versus =.
No need for a regex (using Python 3):
Obviously,
strcontains your input.Since (according to your tag) you are using Python 2.7, I think you need to change the import statement to this, though:
and if you were using Python before version 2.6, the import statement is