RegExp: currency format
I need to format numbers so that thousands are not separated by anything, and hundreds are separated by a dot. for instance
1234.56 12.34 123
I wrote the following ReqExp
amountValue.replace(/^(\d+)[,.](\d{3})[.,](\d{2})$/,'$1' + '$2' +'.'+'$3').replace(/^(\d+),(\d{2})$/,'$1' +'.'+'$2');
If there is a way to make it shorter?
Thanks!
+1
a source to share
2 answers