I have to add commas to this string: 1321654987.00 The result should be: 1,321,654,987.00
I'm trying to use substitutions:
'123123897.00' -replace '^(?<start>(\d{1,3}))(?<mid>(\d{3}))*(?<end>(\.\d{2}))?$','${start},${mid}${end}'
But the result is following: 1,987.00
How can I replace each matched group, not the last one?
Thanks in advance!
$s -replace '(?<!\..*)\B(?=(?:\d{3})+(?:\.\d+)?$)', ','will work, but Mike is right, a regex is not what you really need here.