'Javascript regex remove trailing zeroes after decimal

I know this has been asked many times and I did find a solution, value.replace(/^([\d,]+)$|^([\d,]+)\.0*$|^([\d,]+\.[0-9]*?)0*$/, "$1$2$3").

But... I'm no regex expert so I'm just curious as to why this doesn't work /[\.0]+$/... 10 should return 10 but I just can't figure out how to exclude whole numbers that end with 0s.

1.7500, 1.1010, 1.0000, 10

1.75, 1.101, 1, 1



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source