title: Python regex matching in conditionals
body: <p>I am parsing file and I want to check each line against a few complicated regexs.  Something like this</p>
  
  <pre><code>if re.match(regex1, line): do stuff
  elif re.match(regex2, line): do other stuff
  elif re.match(regex3, line): do still more stuff
  ...
  </code></pre>
  
  <p>Of course, to do the stuff, I need the match objects.  I can only think of three possibilities, each of which leaves something to be desired.</p>
  
  <pre><code>if re.match(regex1, line): 
      m = re.match(regex1, line)
      do stuff
  elif re.match(regex2, line):
      m = re.match(regex2, line)
      do other stuff
  ...
  </code></pre>
  
  <p>which requires doing the complicated matching twice (these are long files and long regex :/) </p>
  
  <pre><code>m = re.match(regex1, line)
  if m: do stuff
  else:
      m = re.match(regex2, line)
      if m: do other stuff
      else:
         ...
  </code></pre>
  
  <p>which gets terrible as I indent further and further.</p>
  
  <pre><code>while True:
      m = re.match(regex1, line)
      if m:
          do stuff
          break
      m = re.match(regex2, line)
      if m:
          do other stuff
          break
      ...
  </code></pre>
  
  <p>which just looks weird.</p>
  
  <p>What's the right way to do this?</p>