This works fine in Chrome
const expression = '(?<=\\d) (\\d\\d\\d)';
const regex = new RegExp(expression, 'gmi');
'123 456'.replace(regex, 'z$1')
// 123z456
However using karma with babelify I get the following error with phantomjs
SyntaxError: Invalid regular expression: unrecognized character after (?
and with Firefox 62.0.0
SyntaxError: invalid regexp group
(same as when using the browser directly)
Is there a plugin that I'm missing ?