Reputation: 47
-I am a beginner python coder so bear with me!
what i have so far is,
def q_4():
pattern = r'^\"\w*\"'
return re.compile(pattern, re.M|re.IGNORECASE)
but for some reason it only returns one instance with one word between the two double quotes. How can i go about grasping full lines?
Upvotes: 1
Views: 139
Reputation: 521804
Try searching on the pattern \"[^"]+\"
:
inp = """Here is a quote: "the quick brown fox jumps over
the lazy dog" and here is another "blah
blah blah" the end"""
dialogs = re.findall(r'\"([^"]+)\"', inp)
print(dialogs)
This prints:
['the quick brown fox jumps over\nthe lazy dog', 'blah\nblah blah']
Upvotes: 1