public String repalceStr(String str){ String arepalce = ""; if(str.length()<=3){ arepalce = str; }else{ String astr1 = ""; String astr2 = ""; int remainder = str.length()%3; if(remainder==0){ arepalce = new ExfinanceServiceImpl().allThreeStr(str); }else{ astr1 = str.substring(0, remainder); astr2 = str.substring(remainder, str.length()); arepalce = new ExfinanceServiceImpl().allThreeStr(astr2); arepalce=astr1+","+arepalce; } } return arepalce; } public String allThreeStr(String threeStr){ String arepalce = ""; int c = threeStr.length()/3; for(int i=0;i<=c-1;i++){ String subi = threeStr.substring(i*3, (i+1)*3); if(i!=c-1){ arepalce +=subi+","; }else{ arepalce +=subi; } } return arepalce; }
字符串修改成1111,111,111形式(3、4、5等类似)
猜你喜欢
转载自wwy0612.iteye.com/blog/2374362
今日推荐
周排行