String, Batch Add Thousands Separators
Detects numbers with more than three digits in the text and adds thousand separators to each number. A comma, dot, or space can be specified as the digit separator. Note that this replacement will also be applied to decimals, postal codes and years.
Download
2022-01-16 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/string-batch-add-thousands-separators-2022/
The Add-on import feature is available with Professional edition.
Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.
Notes
- When the process reaches this automated task, the string data will be automatically converted.
- Numeric characters with more than 4 digits will be replaced.
- This will also apply to postal codes, phone numbers, and the year (2022).
- For example, it makes automatically generated total value reports and sales summary TSVs easier to read.
Capture



Appendix
- Input Sample:
$12345678.90
- Output:
$12,345,678.90
- Output:
- Input Sample: “€12345.00`
- Output:
€12,345.00
- Output:
- Input Sample:
12345678.90123
- Output:
12,345,678.90,123
(not good)
- Output:
- Input Sample:
0120-345-678
- Output:
0,120-345-678
(not good)
- Output:
- Implementation of regular expression replacement (comma added)
- Add digit separator
","
. .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
- Replace all “{number}” with “{number},”.
- But only if immediately followed by the pattern
(\d{3})+(?!\d)
(\d{3})
: three numeric characters(?!\d)
: non-numeric character
- Add digit separator
- Implementation of regular expression replacement (period => comma)
- Replace the decimal period (JavaScript literal) with a comma
.replace(/(\d)\.(?=\d)/g, '$1,')
- Replace all “{number}.” will be replaced with “{number},”.
- But only if immediately followed by
\d
(Lookahead assertion)
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Assertions