'RegEX: Finding any two words on their own line ending in :

Given this body of text:

First Citizen:
Before we proceed any further, hear me speak.
What authority surfeits on would relieve us:
Speak, speak.
ALL:
You are all resolved rather to die than to famish?

I would like to match:

['First Citizen', 'ALL']

I originally tried something like this r'([\w -:]*:)' but want to limit it to lines with only 2 words.

Specifications:

  • Line ends with :
  • Line only has two words or less
  • match those one or two words


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source