title: Matching exact string with JavaScript
body: <p>How can I test if a RegEx matches a string <em>exactly</em>?</p>
  
  <pre><code>var r = /a/;
  r.test("a"); // returns true
  r.test("ba"); // returns true
  testExact(r, "ba"); // should return false
  testExact(r, "a"); // should return true
  </code></pre>