What does this expression return?
'1234567'.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
- '1,234,567'
- '123,456,7'
- '1234,567'
- '1,2,3,4,5,6,7'
It inserts a comma at every inner position followed by a multiple of three digits up to the end.
Play Regex ▸
'1234567'.replace(/\B(?=(\d{3})+(?!\d))/g, ',')