[Java] 纯文本查看 复制代码 public static void main(String[] args) {
String str="1a2,3b4,5c6,7d8,9e10,11f12,13g14,15h16,17i18,19j20,21k22,23l24,25m26,27n28,29o30,31p32,33q34,35r36,37s38,39t40,41u42,43v44,45w46,47x48,49y50,51z52";
String[] str1=str.split(",");
Pattern p=Pattern.compile("[a-z]");
String str2="";
for (String string : str1) {
Matcher m=p.matcher(string);
m.find();
char[] c=m.group(0).toCharArray();
if (c[0]<'y') c[0]=(char)(c[0]+2);
else c[0]=(char)(c[0]-24);
string=string.replaceFirst("[a-z]",String.valueOf(c[0]));
str2=str2.concat(string).concat(",");
}
str2=str2.substring(0, str2.length()-1);
System.out.println(str2);
}
|