如何将字符串中的值从0,00更改为0.00? - 只有数字值,而不是所有字符","到"."
从
string myInputString = "<?xml version=\"1.0\"?>\n<List xmlns:Table=\"urn:www.navision.com/Formats/Table\"><Row><HostelMST>12,0000</HostelMST><PublicMST>0,0000</PublicMST><TaxiMST>0,0000</TaxiMST><ParkMST>0,0000</ParkMST><RoadMST>0,0000</RoadMST><FoodMST>0,0000</FoodMST><ErrorCode>0</ErrorCode><ErrorDescription></ErrorDescription></Row></List>\n";
Run Code Online (Sandbox Code Playgroud)
至
string myInputString = "<?xml version=\"1.0\"?>\n<List xmlns:Table=\"urn:www.navision.com/Formats/Table\"><Row><HostelMST>12.0000</HostelMST><PublicMST>0.0000</PublicMST><TaxiMST>0.0000</TaxiMST><ParkMST>0.0000</ParkMST><RoadMST>0.0000</RoadMST><FoodMST>0.0000</FoodMST><ErrorCode>0</ErrorCode><ErrorDescription></ErrorDescription></Row></List>\n";
Run Code Online (Sandbox Code Playgroud)
感谢您的回答,但我的意思是只更改数值,而不是所有字符","更改为"." 我不希望改变字符串
string = "<Attrib>txt txt, txt</Attrib><Attrib1>12,1223</Attrib1>";
Run Code Online (Sandbox Code Playgroud)
至
string = "<Attrib>txt txt. txt</Attrib><Attrib1>12.1223</Attrib1>";
Run Code Online (Sandbox Code Playgroud)
但是这个还可以
string = "<Attrib>txt txt, txt</Attrib><Attrib1>12.1223</Attrib1>";
Run Code Online (Sandbox Code Playgroud)
试试这个 :
Regex.Replace("attrib1='12,34' attrib2='43,22'", "(\\d),(\\d)", "$1.$2")
Run Code Online (Sandbox Code Playgroud)
输出: attrib1 = '12 .34'attrib2 = '43 .22'
| 归档时间: |
|
| 查看次数: |
1612 次 |
| 最近记录: |