How can I format thousands with dot and decimal with comma?
Input: 3197769.7000000007
Expected: 3.197.769,7000000007
I tried the following regex, but it doesn't feel clean enough. I feel like answer should be similar to How to format a number with commas as thousands separators?, but I don't have enough regex knowledge for it.
const value = 3197769.7000000007
console.log(value.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, "#").replace('.', ',').replace(/#/g, '.'));