输入的数字是全角的。怎么判断它是数字。用java中的正则表达式怎么判断

解决方案 »

  1.   


    public static boolean isNumeric(String str) {
        if (str == null) {
            return false;
        }
        int sz = str.length();
        for (int i = 0; i < sz; i++) {
            if (Character.isDigit(str.charAt(i)) == false) {
                return false;
            }
        }
        return true;
    }
      

  2.   

    全角数字用unicode可以判断。
    Pattern p = Pattern.compile( "[\uff10-\uff19]+");
    Matcher   m   =   p.matcher("01");
    System.out.println("matches :: " + m.matches());