去掉字符串后面所有的0
String t = str.replaceAll("0+$", "");
成对去掉字符串后面所有的0
String str = "9800101092200000"; String t = str.replaceAll("0+$", ""); System.out.println("单个去掉t="+t); System.out.println("成对去掉y="+str.replaceAll("(00)+$", ""));
打印如下:
单个去掉t=98001010922
成对去掉y=980010109220
标签:String,后面,replaceAll,str,字符串,去掉 From: https://www.cnblogs.com/shendidi/p/16818117.html