1234567 -> mathces 1 and 4. 1234567.999 -> matches 1 and 4.
so you can format it to 1,234,567.999 easily
JavaScript: var numberString = "123456789.000"; numberString.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); or numberString.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");