I'm using jquery and I need to switch the order of commas and dots in all numbers.
For example:
120,400.50 -> 120.400,50
Comma for decimals and dot for the rest.
Thanks in advance.
I'm using jquery and I need to switch the order of commas and dots in all numbers.
For example:
120,400.50 -> 120.400,50
Comma for decimals and dot for the rest.
Thanks in advance.
If you want to format the number - you can use the above comment by @Conduit (the possible duplicate).
If you have a known string (with commas and dots) and you want to replace them, you can use a regex with a replacement function:
s = '120,400.50'
console.log(s.replace(/([\.,])/g, a => { return a === '.' ? ',' : '.'} ))