Remove trailing zeros and replace comma [closed]

Multi tool use
Remove trailing zeros and replace comma [closed]
This is my string:
T13
M98P8000;
T14
G0G90X0,000Y-14,000
M3S1818F181
G0G43H13Z-19,750M8
G1Y14,000
But I like this string:
T13
M98P8000;
T14
G0G90X0.Y-14.
M3S1818F181
G0G43H13Z-19.75M8
G1Y14.
I need a function thats delete the last charakter if equal "0",
but it is ímportant that i have the "," or "." sign ater :
Examples:
before: 20,000 after: 20,
before: 20,500 after: 20,5
before: 20,520 after: 20,52
To trade ,
in .
I use:
,
.
File.WriteAllText(path, File.ReadAllText(path).Replace(",", "."));
That's possible. :-)
Then i try to use this:
File.WriteAllText(path, File.ReadAllText(path).TrimEnd('0'));
(Not Check :-( )
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Maybe instead of
TrimEnd
you can Replace
again: File.WriteAllText(path, File.ReadAllText(path).Replace(".000", "."));
?– vasily.sib
Jun 21 at 5:38
TrimEnd
Replace
File.WriteAllText(path, File.ReadAllText(path).Replace(".000", "."));
How do you get from G0G90X0Y-14 to G0G90X0.Y-14.? A Replace will not do that job
– Sir Rufo
Jun 21 at 5:40
Why does
G1Y14
change to G1Y14.
, but T13
and T14
stay the same? If the example is wrong, then please fix the example . If the example is correct, then you need to specify a rule why T13
and T14
should be skipped while G1Y14
is not skipped.– Peter B
Jun 21 at 7:38
G1Y14
G1Y14.
T13
T14
T13
T14
G1Y14
no the example is right T13 and T14 are a static string.
– user3731232
Jun 21 at 15:11
This is probably easily solvable, could you please just paste your desired input and out put more specifically, its a little hard to understand. also, i gather you are trying to add trailing zeros to parts of that string, however can you give possible ways that string will look in regaurds to the lines you are trying to change
– TheGeneral
Jun 21 at 5:17