title: Regex to split text file in python
body: <p>I am trying to find a way to parse a string of a transcript into speaker segments (as a list). Speaker labels are denoted by the upper-casing of the speaker's name followed by a colon. The problem I am having is some names have a number of non upper-case characters. Examples might include the following:</p>
  
  <p>OBAMA: said something</p>
  
  <p>O'MALLEY: said something else</p>
  
  <p>GOV. HICKENLOOPER: said something else entirely'</p>
  
  <p>I have written the following regex, but I am struggling to get it to work:</p>
  
  <pre><code>mystring = "OBAMA: said something \nO'MALLEY: said something else \nGOV. HICKENLOOPER: said something else entirely"
  
  parse_turns = re.split(r'\n(?=[A-Z]+(\ |\.|\'|\d)*[A-Z]*:)', mystring)
  </code></pre>
  
  <p>What I think I have written (and ideally what I want to do) is a command to split the string based on:</p>
  
  <p><b>1.</b> Find a newline</p>
  
  <p><b>2.</b> Use positive look-ahead for one or more uppercase characters</p>
  
  <p><b>3.</b> If upper-case characters are found look for optional characters from the list of periods, apostrophes, single spaces, and digits</p>
  
  <p><b>4.</b> If these optional characters are found, look for additional uppercase characters.</p>
  
  <p><b>5.</b> Crucially, find a colon symbol at the end of this sequence.</p>
  
  <p><b>EDIT:</b> In many cases, the content of the speech will have newline characters contained within it, and possibly colon symbols. As such, the only thing separating the speaker label from the content of speech is the sequence mentioned above. </p>