title: Regex: don't match string ending with newline (\n) with end-of-line anchor ($)
body: <p>I can't figure out how to match a string but not if it has a trailing newline character (<code>\n</code>), which seems automatically stripped:</p>
  
  <pre><code>import re
  
  print(re.match(r'^foobar$', 'foobar'))
  # &lt;_sre.SRE_Match object; span=(0, 6), match='foobar'&gt;
  
  print(re.match(r'^foobar$', 'foobar\n'))
  # &lt;_sre.SRE_Match object; span=(0, 6), match='foobar'&gt;
  
  print(re.match(r'^foobar$', 'foobar\n\n'))
  # None
  </code></pre>
  
  <p>For me, the second case should also return <code>None</code>.<br>
  When we set the end of a pattern with <code>$</code>, like <code>^foobar$</code>, it should only match a string like <code>foobar</code>, not <code>foobar\n</code>.</p>
  
  <p>What am I missing?</p>