Reputation:
I have this group of numbers: 1 000 , 30 000 , 400 000 on some text files and it's a lot of them. I want to search all of this group numbers and add between them a dot or comma , like this 1,000 or this 1.000.
I know I can find them like this : \d \d\d\d
, but I don't know what do next to replace that white space with a comma or a dot.
Upvotes: 2
Views: 46
Reputation: 91385
If you regex flavour supports lookaround, you can do:
(?<=\d)\s+(?=\d)
,
or .
if it doesn't:
(\d)\s+(\d)
$1,$2
or $1.$2
Both will replace a space between 2 digits with a comma or a dot
Upvotes: 1