So I have this code:
1 | function addCommas(str) |
2 | return #str % 3 = = 0 and str:reverse():gsub( "(%d%d%d)" , "%1," ):reverse():sub( 2 ) or str:reverse():gsub( "(%d%d%d)" , "%1," ):reverse() |
3 | end |
But, that's way to complex for me. I need a way to more simply insert commas into numbers above 999.