I am trying to match all consecutive all caps words/phrases using regex in Python. Given the following:
text = "The following words are ALL CAPS. The following word is in CAPS."
The code would return:
ALL CAPS, CAPS
I am currently using:
matches = re.findall('[A-Z\s]+', text, re.DOTALL)
But this returns:
['T', ' ', ' ', ' ', ' ALL CAPS', ' T', ' ', ' ', ' ', ' ', ' CAPS']
I clearly don't want the punctuation or the 'T'. I want to return only consecutive words or a single word that only include all capital letter.
Thanks