判断字符的类型

private static CharType getType(char c) {
        CharType tag;
        int type = Character.getType(c);
        if (Character.isLowerCase(c)||Character.isUpperCase(c)){
            tag = CharType.L;
        } else if (c == 12288 || c == 32) {//Character.isWhitespace(c) || Character.isSpaceChar(c)
            tag = CharType.B;
        } else if (Character.isDigit(c)) {
            tag = CharType.D;
//        }else if ("一二三四五六七八九十零〇○".indexOf(c) != -1) {
//            tag[i] = CharType.NUM;
        } else if (type>=20&&type<=30){
//            punP.matcher(String.valueOf(c)).matches()){//"/—-()。!,\"'()!,””<>《》::#@¥$%^…&*!、.%".
            tag = CharType.P;
            
        } else {
            tag =CharType.C;
        }
        return tag;
    }

 

posted on 2013-09-06 13:53  ywf—java  阅读(588)  评论(0编辑  收藏  举报

导航