标签:nbsp style || bsp code name spl rar asc
@Test void contextLoads() { String str ="!dasd_asda_dasjdlkaj"; System.out.println(a(str)); } //截取字符串 转换大写并且输出 String a(String name) { String[] str= {}; StringBuilder sb = new StringBuilder(); str = name.split("_"); for (int i=0; i<str.length;i++ ){ str[i] = text(str[i]); } for (int j = 0;j<str.length;j++){ if(j==str.length-1){ sb.append(str[j]); return sb.toString(); } sb.append(str[j]).append("_"); } return sb.toString(); } //转化大小写 String text(String name){ char[] ca = name.toCharArray(); //ascii 码范围 if (ca[0]>=65&&ca[0]<=90 || ca[0]<90||ca[0]>122){ return String.valueOf(ca); } ca[0]-=32; return String.valueOf(ca); }
标签:nbsp style || bsp code name spl rar asc
原文地址:https://www.cnblogs.com/bxzmd/p/14620595.html