대륙 홍콩, 마카오, 대만 신분증 정규 검증

대륙 홍콩, 마카오, 대만 신분증 정규 검증
  public static boolean getisIdCard(String str) {
     

        //1.   18       X
        String Dalu = "([1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2]   [1-9])|10|20|30|31)\\d{3}[0-9Xx])|([1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3})";
        Pattern p = Pattern.compile(Dalu);
        Matcher m = p.matcher(str);
        boolean matches = m.matches();

        //  8    :  X354670(A)      
        String Hongkong = "[A-Za-z]{1}\\d{6}[(\\d)|A]{3}";
        Pattern p2 = Pattern.compile(Hongkong);
        Matcher m2 = p2.matcher(str);
        boolean matches2 = m2.matches();

        //  10   : U193683453  
        String Taiwan ="[A-Z]{1}\\d{9}";
        Pattern p3 = Pattern.compile(Taiwan);
        Matcher m3 = p3.matcher(str);
        boolean matches3 = m3.matches();


        //  8   :5686611(1)  
        String Macao = "[1|5|7]\\d{6}[(\\d)]{3}";
        Pattern p1 = Pattern.compile(Macao);
        Matcher m1 = p1.matcher(str);
        boolean matches1 = m1.matches();

        if(matches||matches1||matches2||matches3){
     
            return true;
        }


        return false;
    }

좋은 웹페이지 즐겨찾기