Given a string of digits, remove leading zeros from it.
Input : 00000123569 Output : 123569 Input : 000012356090 Output : 12356090
1) Count leading zeros.
2) Use StringBuffer replace function to remove characters equal to above count.
This article is contributed by Mr. Somesh Awasthi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Remove leading zeros from an array
- Python | Remove leading zeros from an IP address
- Trim (Remove leading and trailing spaces) a string in Java
- Remove Trailing Zeros From string in C++
- All possible numbers of N digits and base B without leading zeros
- Comparing leading zeros in binary representations of two numbers
- Number of leading zeros in binary representation of a given number
- Remove extra delimiter from a String in Java
- Remove all non-alphabetical characters of a String in Java
- How to remove all white spaces from a String in Java?
- Maximum difference of zeros and ones in binary string
- Maximum difference of zeros and ones in binary string | Set 2 (O(n) time)
- Remove characters from the first string which are present in the second string
- Remove "b" and "ac" from a given string
- Remove duplicates from a given string