I have a string like this-:
st = "url=these,url=are,url=test,url=questions"
Now from this string i need to generate value of all the url. Now the regexp am using is something like this-:
import re
re.findall(r'([^\(url=\)]+)',st)
Now my desired output is ['these,', 'are,', 'test,', 'questions'] but my regexp is giving
['these,', 'a', 'e,', 'test,', 'q', 'estions'] this as output.
So, what should be my modified regexp and why my regexp is not giving me the desired output.
You’ve used square brackets
[]which select characters. You’ve got[^\(url=\)]which matches any character except (, u, r, l, = and ).Instead, you want
url=([^,]+)which matches ‘url=’ then proceeds to match until it finds a non-comma character.