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"); // should return false testExact(r, "a"); // should return true
Write your regex differently:
var r = /^a$/; r.test('a'); // true r.test('ba'); // false