时间:2021-05-04 10:48:54 | 栏目:JAVA代码 | 点击:次
方式一:
例如:”0000123” (字符串必须全为数字)
处理过程:
String tempStr = "0000123"; int result = Integer.parseInt(tempStr);
result 结果:123
方式二:
例如:”0000123”
处理过程:
String str = "0000123";
String newStr = str.replaceFirst("^0*", "");
System.out.println(newStr);
打印结果:123
方式三:
例如:”0000123”
处理过程:
String str = "0000123";
String newStr = str.replaceAll("^(0+)", "");
System.out.println(newStr);
打印结果:123