lookbehindってこれ?
'$foo %foo foo'.replace(/(?<=\$)foo/g, 'bar');
// => "$bar %foo foo"
ES2018だけど手元のChromeで普通に動くな