Q:

Is it possible in JS to define regexp that would give false when testing on given text in the end of input?

I need a regexp pattern in JS that that would give false when testing on given text in the end of input.
For example:
/(?!not this text)$/.test("blablabla not this text") === false
/(?!not this text)$/.test("blablabla     this text") === true

But it won't work that way! Here's some experiment:
console.log("<expected>: <actual>");
console.log("false:"  + /^(?!<asd>)/.test("<asd>"));
console.log("true:"   + /^(?!<asd>)/.test("<asg>"));
console.log("false:"  + /(?!<asd>)$/.test("<asd>"));
console.log("true:"   + /(?!<asd>)$/.test("<asg>"));
console.log("false:"  + /(<asd>){0}$/.test("<asd>"));
console.log("true:"   + /(<asd>){0}$/.test("<asg>"));

Gives output:
<expected>: <actual>
false:false
true:true
false:true
true:true
false:true
true:true

Question:
Is it possible in JS to define regexp that would give false when testing on given text in the end of input?

A:

Yes, it's possible:
/^(?:(?!not this text$).)*$/

Note that the regex must be anchored at both ends, and the lookahead subexpression must be anchored at the end but not at the beginning.
Another way to do it is:
/^(?!.*not this text$).*$/

Again, the regex as a whole has to be anchored at both ends for this to work.

