Skip to main content

Java and php one line of code to remove leading zeros from a string

php

$str = ltrim($str, '0');


java
str.replaceFirst("^0+(?!$)", "")

Comments