zoukankan      html  css  js  c++  java
  • java去中文

    java 去中文 

    package a.b;
    
    public class TrimCNTool {
        
        public static boolean checkCNChar(char oneChar) {
            if ((oneChar >= 'u4e00' && oneChar <= 'u9fa5')  || (oneChar >= 'uf900' && oneChar <= 'ufa2d')){
                return true;
            }else{
                return false;
            }
        }
     
        public static String deleteCNChar(String source) {
            char[] cs = source.toCharArray();
            int length= cs.length;
            char [] buf = new char[length];
            for (int i = 0; i <length; i++) {
                char c = cs[i];
                if (!checkCNChar(c)) {
                    buf[i] = c;
                }
            }
            String ret = new String(buf);
            return ret.trim();
        }
     
        public static void main(String[] args) {
            String string = "很高兴遇见你Mr. King ";
            string = deleteCNChar(string);
            System.out.println(string);
        }
    }
  • 相关阅读:
    Javascript 进阶
    transform顺序浅谈
    js对象克隆
    js动画最佳实现——requestAnimationFrame
    svg标签
    typeof和instanceof
    js变量浅谈
    X-UA-compatible浅谈
    封装$
    面向对象
  • 原文地址:https://www.cnblogs.com/whatlonelytear/p/5091689.html
Copyright © 2011-2022 走看看