简体   繁体   English

如何在两个数字之间添加空格-Regex.Replace()

[英]How to add a white space between two numbers -Regex.Replace()

Someone knows how to add a white space between two number when they do not have an space. 有人知道当两个数字之间没有空格时如何在它们之间添加空格。 So I have #,###,## and want #,## #,## 所以我有#,###,##想要#,###,## #,## #,##

I have this: 我有这个:

2.100.000,000,04
300,450,06
23,011,87
54.845,37462.521,21

I want this: 我要这个:

2.100.000,00 0,04
300,45 0,06
23,01 1,87
54.845,37 462.521,21

In order to see if a replace should occur I did this expression \\,([0-9]{3})\\, 为了查看是否应该进行替换,我做了以下表达式\\,([0-9]{3})\\,

Thanks for your help. 谢谢你的帮助。

Update 1 更新1

  • Number format could be #.###.###,## (always with two decimals) 数字格式可以是#.###.###,## (始终带有两个小数)

$1 $2替换(,\\d{2})(\\d,)出现( $1$2是对捕获组的引用,具体取决于您可能需要使用\\1 \\2的语言或工具)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM