I also saw it as + $.
I use
$(this).text( $(this).text().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") );
To convert 10,000 to 10,000, etc.
I think I understand everything:
- (\ d) - find the number
- (? = \ d {3}) - if you follow 3 numbers
- '+' - do not stop after the first search
- (?! \ d) - starting from the last number?
- / g - for the whole line
- "$ 1" - replace the number with self and comma
source
share