使用RegEx将dot(。)替换为逗号(,)?
我正在开发C#应用程序。我想使用正则表达式用逗号(,)更改数字十进制数字。
I am working on a C# application. I want to change number decimal figure with comma(,) where i have dot(.) using regular expression.
例如:
Price= 100,00.56
表示数字值的国际规则,但我在瑞典使用数字的不同方式,例如
As this international rule of representing numeric values but I Sweden they have different ways for numbers Like
Price= 100.00,56
所以我想使用以下方式将dot(。)更改为逗号(,)并将逗号(,)更改为dot(。)正则表达式。可以为我提供指导。
So i want to change dot(.) into comma(,) and comma(,) into dot(.) using RegEx. Could guide me about this.
在格式化数字时,应使用字符串格式重载,它需要 CultureInfo
对象。瑞典的文化名称为 sv-SE,如此处所示。
When formatting numbers, you should use the string format overload that takes a CultureInfo
object. The culture name for swedish is "sv-SE", as can be seen here.
decimal value = -16325.62m;
Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("sv-SE")));
编辑:
@OregonGhost指出-解析数字也应使用 CultureInfo
。
As @OregonGhost points out - parsing out numbers should also be done with CultureInfo
.