I wish to match a url string with my regex pattern: r'.+'.
I expect this pattern to fully match the url string, but that's not happening. I'm getting the following output:
Output:
url string: https://stackoverflow.com/users/signup?ssrc=head&returnurl=%2fusers%2fstory%2fcurrent
matched string: <re.Match object; span=(0, 85), match='https://stackoverflow.com/users/signup?ssrc=head&>
Clearly, the match leaves out a chunk of the url string by the end. My pattern doesn't match the returnurl=%2fusers%2fstory%2fcurrent part of the url string. Why is this happening? Should I be using something other than r'.+' for my pattern?
Code:
def getQueryParameters(url):
print(f"url string: {url}")
pattern = re.compile(r'.+')
match = pattern.search(url)
print(f'matched string: {match}')
if __name__ == '__main__':
url = "https://stackoverflow.com/users/signup?ssrc=head&returnurl=%2fusers%2fstory%2fcurrent"
getQueryParameters(url)