Answers for "string.format to add leading zeros"

1

replace 2 leading zeros from string

String str = "00051700";
String strPattern = "^0+";        
System.out.println( "String: " + str.replaceAll(strPattern, "") );
Posted by: Guest on May-21-2020
0

print number with leading zeros

int n = 123;
printf("%0.5d", n); // 00123
Posted by: Guest on April-30-2021

Code answers related to "string.format to add leading zeros"

Python Answers by Framework

Browse Popular Code Answers by Language