How can I test if a RegEx matches a string exactly?
var r = /a/; r.test(\"a\"); // returns true r.test(\"ba\"); // returns true testExact(r, \"ba\")
If you do not use any placeholders (as the "exactly" seems to imply), how about string comparison instead?
If you do use placeholders, ^ and $ match the beginning and the end of a string, respectively.
^
$