I have the following string values.
00000062178221
00000000054210
00004210555001
How can I cleanup the string and remove the zero paddings from the left? I'm using C# and .net 2.0. Expected results from above:
62178221
54210
4210555001
This should be pretty efficient
string str = "000001234";
str = str.TrimStart('0');
string s = "0001234";
s = s.TrimStart('0');
You might want to add
if (s == "") s = "0";
to avoid converting 00000000
to an empty string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With