title: Regex: How to match sequence of key-value pairs at end of string
body: <p>I am trying to match key-value pairs that appear at the end of (long) strings. The strings look like (I replaced the "\n")</p>
  
  <pre><code>my_str = "lots of blah
            key1: val1-words
            key2: val2-words
            key3: val3-words"
  </code></pre>
  
  <p>so I expect matches "key1: val1-words", "key2: val2-words" and "key3: val3-words".</p>
  
  <ul>
  <li>The set of possible key names is known.</li>
  <li>Not all possible keys appear in every string.</li>
  <li>At least two keys appear in every string (if that makes it easier to match).</li>
  <li>val-words can be several words.</li>
  <li>key-value pairs should only be matched at the end of string.</li>
  <li>I am using Python re module.</li>
  </ul>
  
  <p>I was thinking <pre><code>re.compile('(?:tag1|tag2|tag3):')</pre></code></p>
  
  <p>plus some look-ahead assertion stuff would be a solution. I can't get it right though. How do I do?</p>
  
  <p>Thank you.</p>
  
  <p>/David</p>
  
  <p>Real example string:</p>
  
  <pre><code>my_str = u'ucourt métrage pour kino session volume 18\nThème: O sombres héros\nContraintes: sous titrés\nAuthor: nicoalabdou\nTags: wakatanka productions court métrage kino session humour cantat bertrand noir désir sombres héros mer medine marie trintignant femme droit des femmes nicoalabdou pute soumise\nPosted: 06 June 2009\nRating: 1.3\nVotes: 3'
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Based on Mikel's solution I am now using the following:</p>
  
  <p><pre><code>
  my_tags = ['\S+'] # gets all tags
  my_tags = ['Tags','Author','Posted'] # selected tags
  regex = re.compile(r'''
      \n                     # all key-value pairs are on separate lines
      (                      # start group to return
         (?:{0}):            # placeholder for tags to detect '\S+' == all
          \s                 # the space between ':' and value
         .*                  # the value
      )                      # end group to return
      '''.format('|'.join(my_tags)), re.VERBOSE)</p>
  
  <p>regex.sub('',my_str) # return my_str without matching key-vaue lines
  regex.findall(my_str) # return matched key-value lines
  </pre></code></p>