For example... (this fails)
const currencyMap = {
"$": "USD",
"€": "EUR",
};
const r = '$100'.replace(/(\$)([0-9]*)/g, `${currencyMap[$1]}$2`);
console.log(r);
Is there a way to make this sort of thing work?
$1 is available when it's used in a string, but not as a key.