goja-core/src/main/java/goja/core/kits/IdCardKit.java
public static String[] validateIdCard10(String idCard) {
        String[] info = new String[3];
        String card = idCard.replaceAll("[\\(|\\)]", "");
        if (card.length() != 8 && card.length() != 9 && idCard.length() != 10) {
            return null;
        }
        if (idCard.matches("^[a-zA-Z][0-9]{9}$")) { // 台湾
            info[0] = "台湾";
            System.out.println("11111");
            String char2 = idCard.substring(1, 2);
            if (char2.equals("1")) {
                info[1] = "M";
                System.out.println("MMMMMMM");
            } else if (char2.equals("2")) {
                info[1] = "F";
                System.out.println("FFFFFFF");
            } else {
                info[1] = "N";
                info[2] = "false";
                System.out.println("NNNN");
                return info;
            }
            info[2] = validateTWCard(idCard) ? "true" : "false";
        } else if (idCard.matches("^[1|5|7][0-9]{6}\\(?[0-9A-Z]\\)?$")) { // 澳门
            info[0] = "澳门";
            info[1] = "N";
            // TODO
        } else if (idCard.matches("^[A-Z]{1,2}[0-9]{6}\\(?[0-9A]\\)?$")) { // 香港
            info[0] = "香港";
            info[1] = "N";
            info[2] = validateHKCard(idCard) ? "true" : "false";
        } else {
            return null;
        }
        return info;
    }
public static String[] validateIdCard10(String idCard) {
        String[] info = new String[3];
        String card = idCard.replaceAll("[\\(|\\)]", "");
        if (card.length() != 8 && card.length() != 9 && idCard.length() != 10) {
            return null;
        }
        if (idCard.matches("^[a-zA-Z][0-9]{9}$")) { // 台湾
            info[0] = "台湾";
            System.out.println("11111");
            String char2 = idCard.substring(1, 2);
            if (char2.equals("1")) {
                info[1] = "M";
                System.out.println("MMMMMMM");
            } else if (char2.equals("2")) {
                info[1] = "F";
                System.out.println("FFFFFFF");
            } else {
                info[1] = "N";
                info[2] = "false";
                System.out.println("NNNN");
                return info;
            }
            info[2] = validateTWCard(idCard) ? "true" : "false";
        } else if (idCard.matches("^[1|5|7][0-9]{6}\\(?[0-9A-Z]\\)?$")) { // 澳门
            info[0] = "澳门";
            info[1] = "N";
            // TODO
        } else if (idCard.matches("^[A-Z]{1,2}[0-9]{6}\\(?[0-9A]\\)?$")) { // 香港
            info[0] = "香港";
            info[1] = "N";
            info[2] = validateHKCard(idCard) ? "true" : "false";
        } else {
            return null;
        }
        return info;
    }
public static String [ ] validateIdCard10 ( String idCard ) { String [ ] info = new String [ 3 ] ; String card = idCard . replaceAll ( "[\\(|\\)]" , "" ) ; if ( card . length ( ) != 8 && card . length ( ) != 9 && idCard . length ( ) != 10 ) { return null ; } if ( idCard . matches ( "^[a-zA-Z][0-9]{9}$" ) ) { // 台湾 info [ 0 ] = "台湾"; System . out . println ( "11111" ) ; String char2 = idCard . substring ( 1 , 2 ) ; if ( char2 . equals ( "1" ) ) { info [ 1 ] = "M" ; System . out . println ( "MMMMMMM" ) ; } else if ( char2 . equals ( "2" ) ) { info [ 1 ] = "F" ; System . out . println ( "FFFFFFF" ) ; } else { info [ 1 ] = "N" ; info [ 2 ] = "false" ; System . out . println ( "NNNN" ) ; return info ; } info [ 2 ] = validateTWCard ( idCard ) ? "true" : "false" ; } else if ( idCard . matches ( "^[1|5|7][0-9]{6}\\(?[0-9A-Z]\\)?$" ) ) { // 澳门 info [ 0 ] = "澳门"; info [ 1 ] = "N" ; // TODO } else if ( idCard . matches ( "^[A-Z]{1,2}[0-9]{6}\\(?[0-9A]\\)?$" ) ) { // 香港 info [ 0 ] = "香港"; info [ 1 ] = "N" ; info [ 2 ] = validateHKCard ( idCard ) ? "true" : "false" ; } else { return null ; } return info ; }
验证10位身份编码是否合法

@param idCard 身份编码
@return 身份证信息数组 <p> [0] - 台湾、澳门、香港 [1] - 性别(男M,女F,未知N) [2] - 是否合法(合法true,不合法false)
若不是身份证件号码则返回null </p>
验证10位身份编码是否合法