日期:2014-05-20 浏览次数:20773 次
public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String tr = "999SBfdfdf dfdf "; char[] c = tr.toCharArray(); StringBuffer sb = new StringBuffer(); for(int i=0;i<c.length;i++){ sb.delete(0, sb.length()); if(sb.append(c[i]).toString().matches("[a-zA-Z]+|\\s")) { System.out.print(c[i]);//如果是空格或字母全部输出 } } } }