3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Ene Uran
1

re.search() returns a MatchObejct, not the string that matches the regex.
Look up in the docs what you can do with it to get the match string.

A better regex to use is

matchObj = re.search('(?<=http://user.url.com/)[^"]+', pg_r)
if matchObj:
    pass # found a match
Votes + Comments
Thanks for helping me with regular expressions! o.o
0

Thank you so much! Problem solved. Also, thanks for the insight into what type is returned.

0

Also in Python3 'pg_r' would be a byte string and module re will complain without converting 'pg_r' to a string first.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.