I want to extract words in quotation marks if they are one or two words long. This works with the following Code.
mysentences = ['Kids, you "tried" your "best" and you failed miserably. The "lesson" is, "never try."',
"Just because I don’t 'care' doesn’t mean I don’t understand."]
quotation = []
rx = r'"((?:\w+[ .]*){1,2})"'
for sentence in mysentences:
quotation.append(re.findall(rx, sentence))
print(quotation)
But this doesn't get me the 'care' from the sencond sentence because the second sentence is in double quotation marks. I can get it with the following
r"'((?:\w+[ .]*){1,2})'"
The Question is, how can I join the conditions? with
rx = r'"((?:\w+[ .]*){1,2})"' or r"'((?:\w+[ .]*){1,2})'"
it only gets me the first mentioned condition.