Q:

Javascript Look behind

I'm trying to mimic a look behind in Javascript, 
I want to match the string "object.all" but not "object.call".  I've tried:
new RegExp('(?!(\\.))all')

But both examples are matched, what I want is a look behind to test if there's a . ( dot) just behind all, can someone explain me what's wrong in my regex? 
Thanks in advance

This one is good:
'object.all'.replace(new RegExp('(?!(\\.))all'), 'foo') 
// => object.foo

For this one i expect the result to be "object.call" :
'object.call'.replace(new RegExp('(?!(\\.))all'), 'foo')
// => object.cfoo

A:

Though this seems complex this will get the job done:
function replaceAll(string, replacement) {
  var output = string.replace(/(\.)?all/g, function($0, $1) {
    return $1 ?  $1 + replacement : $0;
  });
  return output;
}

var test1 = replaceAll("object.all", "foo");
var test2 = replaceAll("object.call", "foo");

console.log(test1); // object.foo
console.log(test2); // object.call

I have used the article (Mimicking Lookbehind in JavaScript) that @m.buettner linked in the comments before in a bit of code I was working on earlier this year.