记录一下小的工具代码

1、去掉字符串前边的0

String str = "000000021";
String newStr = str.replaceAll("^(0+)", "");
System.out.println(newStr);

2、去掉字符串后边的0

String str = "2100000";
String newStr = str.replaceAll("0*$", "");
System.out.println(newStr);

两种方法结果均为21

相关文章:

  • 2021-11-17
  • 2022-01-21
  • 2022-12-23
  • 2021-12-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-03-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案