http://www.foobar.com/foo/foo_bar.html?id=abc12A63768adv
http://www.foobar.com/foo/foo_bar.html?id=gsdfcc6tfsdfgg
http://www.foobar.com/foo/foo_bar.html?id={8765ABDV-8876-CR56-654A-ADD}
These are the url pattern for which I have to write a regex.
re.compile('http://www.foobar.com/foo/foo_bar.html?id=+[a-zA-Z0-9-{}]+$')
But this is not working for me.
You must escape (by prepending
\) the?else it will be interpreted as an “optional” flag for the preceding part of the regex. Then, you should escape the dots, else they will match any character.Then, you should move the
-(dash) you are trying to match to the front of your[]list, so that the regex will be obviously including the dash and not using the dash as another range.Finally, you may wish to put
^on the front so that you always match from the beginning, similar to how you used$on the end.