title: Python regex match whole string only
body: <p>Is there any easy way to test whether a regex matches an entire string in Python? I thought that putting <code>$</code> at the end would do this, but it turns out that <code>$</code> doesn't work in the case of trailing newlines.</p>
  
  <p>For example, the following returns a match, even though that's not what I want.</p>
  
  <pre><code>re.match(r'\w+$', 'foo\n')
  </code></pre>