标签:
给一字符串如a2bc3d1 转换成aabcbcbcd
1 String decode(String str) { 2 String word=""; 3 StringBuilder result=new StringBuilder(""); 4 for(int i=0;i<str.length();i++) 5 { 6 String temp=str.charAt(i)+""; 7 if(temp.matches("[a-z]")) 8 { 9 result.append(temp); 10 word+=temp; 11 } 12 else 13 { 14 int times=Integer.parseInt(temp)-1; 15 for(int j=0;j<times;j++) 16 result.append(word); 17 word=""; 18 } 19 } 20 return result.toString(); 21 22 }
标签:
原文地址:http://www.cnblogs.com/sweetculiji/p/4356430.html