Here is the code I have so far:

import re
from urllib.request import urlopen

pg = urlopen('')
pg_r =
print('(?<=\w+', pg_r))

What I *want* to do with is find the word between the strings '' and '"' but I'm not sure how to do that..
Can anyone help me with the regular expression for that?

Recommended Answers

All 3 Replies 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 ='(?<=[^"]+', pg_r)
if matchObj:
    pass # found a match
commented: Thanks for helping me with regular expressions! o.o +1

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.