I have a filename that can have multiple dots in it and could end with any extension:
tro.lo.lo.lo.lo.lo.png
I need to use a regex to repla
Just use special replacement pattern $1 in the replacement string:
$1
console.log("tro.lo.lo.lo.lo.lo.png".replace(/\.([^.]+)$/, "@2x.$1")); // "tro.lo.lo.lo.lo.lo@2x.png"