Remove leading zeroes but not all zeroes in C#

I have the string value 000001 and need to get the last three digits - 001

Zeroes quantity before 001 can be different and the value itself can be two or three digits/chars e.x. 011 or 111

There is a way to remove all leading zeros value.TrimStart('0') but how to keep zeros that are in scope of the last three chars?

Is there a way to trim till specified chars left?



Read more here: https://stackoverflow.com/questions/66993536/remove-leading-zeroes-but-not-all-zeroes-in-c-sharp

Content Attribution

This content was originally published by lia at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: