Sorry for reviving an old thread – wanted to give a general solution here (if only so I can find it in google search if I need it again, haha).
Uses functions, requires TW 5.3+:
\define local.separate-number.regex() (\d)(?=(\d{3})+(?!\d))
\define local.separate-number.replacement() $1$(separator)$
\function my.separate-number-input(separator:",")
[search-replace:g:regexp<local.separate-number.regex>,<local.separate-number.replacement>]
\end my.separate-number-input
\function my.separate-number(number, separator:",")
[<number>my.separate-number-input<separator>]
\end my.separate-number
Add to a new tiddler tagged $:/tags/Global
and you can use anywhere:
<<my.separate-number 1234>>
1,234
Or:
{{{ [[5000]my.separate-number-input[]] }}}
5,000
Or if you’re in a locale that uses periods in this situation:
<<my.separate-number 1234567 ".">>
1.234.567