Skip to content
Advertisement

removes leading zeroes, but leaves one necessary From String in Java

Given:

JavaScript

How do I remove leading zeros but leaves one necessary

This is the output I’m expecting:

JavaScript

Currently, am using this function but i need to optimize it :

JavaScript

can anyone help me please ? thank you for advanced

Advertisement

Answer

You can use this regex ^0*(0d+) like this:

JavaScript

I/O

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement