Test, validate and match regular expressions
Matches a single digit that is followed by one or more groups of exactly three digits before a word boundary, using a positive lookahead so the trailing digits aren't consumed. Its primary use is inserting thousands separators into large numbers: replacing each match with '$1,' turns 1234567 into 1,234,567. The global flag ensures a comma is inserted at every valid position.