title: Backreferencing in Python: findall() method output for HTML string
body: <p>I am trying to learn some regular expressions in Python. The following does not produce the output I expected:</p>
  
  <pre><code>with open('ex06-11.html') as f:
      a = re.findall("&lt;div[^&gt;]*id\\s*=\\s*([\"\'])header\\1[^&gt;]*&gt;(.*?)&lt;/div&gt;", f.read())
      # output: [('"', 'Some random text')]
  </code></pre>
  
  <p>The output I was expecting (same code, but without the backreference):</p>
  
  <pre><code>with open('ex06-11.html') as f:
      print re.findall("&lt;div[^&gt;]*id\\s*=\\s*[\"\']header[\"\'][^&gt;]*&gt;(.*?)&lt;/div&gt;", f.read())
      # output: ['Some random text']
  </code></pre>
  
  <p>The question really boils down to: why is there a quotation mark in my first output, but not in my second? I thought that <code>([abc]) ... //1</code> == <code>[abc] ... [abc]</code>. Am I incorrect?</p>