# Summary When replacing with a value that contains $<number>, the value is truncated of $ and first number. # Test var string = "Get %{amount} credit"; var regex = new RegExp(`%{amount}`, "g"); console.log(string.replace(regex, "$100")); # Expected > Get $100 credit # Actual > Get 00 credit
This could be related to a non-standard feature: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/n#Examples
<rdar://problem/54306164>
After further investigation, this issue looks to be caused by an old String.prototype.replace polyfill from core-js@2.0.3. Ref: https://github.com/zloirock/core-js/blob/v2.0.3/modules/es6.regexp.replace.js