如题!!先谢了...

解决方案 »

  1.   

    论坛里边找找吧,好象有,不行就baidu
      

  2.   

    最好是JAVA算法,判断15位身份证号是否为有效的号码..
      

  3.   

    仅供参考
    -------------
    /**
     * project_name: Test
     * package_name: csdn_Test_20071126
     * package_declaration: package csdn_Test_20071126;
     * filename: CheckCetiType.java
     * author: yuhaiming
     * date: 2007-12-5
     */
    package csdn_Test_20071126;import java.text.SimpleDateFormat;public class CheckCetiType {
    /**
     * 检查校验位
     * @param certiCode
     * @return
     */
    private static boolean checkIDParityBit(java.lang.String certiCode) {
    boolean flag = false;
    if (certiCode == null || "".equals(certiCode))
    flag = false;
    int ai[] = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 };
    if (certiCode.length() == 18) {
    int i = 0;
    boolean flag1 = false;
    for (int k = 0; k < 18; k++) {
    char c = certiCode.charAt(k);
    int j;
    if (c == 'X' || c == 'x')
    j = 10;
    else if (c <= '9' || c >= '0')
    j = c - 48;
    else
    return flag;
    i += j * ai[k];
    } if (i % 11 == 1)
    flag = true;
    }
    return flag;
    }
    /**
     * 检查日期格式
     * @param year
     * @param month
     * @param day
     * @return
     */
    private static boolean checkDate(java.lang.String year, java.lang.String month,
    java.lang.String day) {
    java.text.SimpleDateFormat simpledateformat = new SimpleDateFormat(
    "yyyyMMdd");
    try {
    java.lang.String s3 = year + month + day;
    simpledateformat.setLenient(false);
    simpledateformat.parse(s3);
    //str2Date(bankCode,s3);
    } catch (java.text.ParseException parseexception) {
    com.ulic.life.webservice.log.Log.error(
    "校验日期出错:",
    parseexception);
    return false;
    }
    return true;
    }
    /**
     * 校验身份证
     * @param certiCode 待校验身份证
     * @return 0--校验成功<br>
     *         1--位数不对<br>
     *         2--生日格式不对<BR>
     *         3--校验位不对<BR>
     *         4--其他异常
     */
    public static int checkCertiCode(java.lang.String certiCode) {
    try {
    if (certiCode == null || certiCode.length() != 15 && certiCode.length() != 18)
    return 1;
    java.lang.String s1;
    java.lang.String s2;
    java.lang.String s3; if (certiCode.length() == 15) {
    s1 = "19" + certiCode.substring(6, 8);
    s2 = certiCode.substring(8, 10);
    s3 = certiCode.substring(10, 12); if (!checkDate(s1,s2, s3))
    return 2;
    } if (certiCode.length() == 18) { s1 = certiCode.substring(6, 10);
    s2 = certiCode.substring(10, 12);
    s3 = certiCode.substring(12, 14); if (!checkDate(s1,s2, s3))
    return 2;
    if (!checkIDParityBit(certiCode))
    return 3;
    }
    } catch (java.lang.Exception exception) { com.ulic.life.webservice.log.Log.error(
    "校验身份证出错:",
    exception);
    return 4;
    }
    return 0;
    }
    /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    String cetitype = "361502195410086812";
    checkCertiCode(cetitype);
    }}
      

  4.   

    根据〖中华人民共和国国家标准   GB   11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。     
        
          地址码表示编码对象常住户口所在县(市、旗、区)的行政区划代码。生日期码表示编码对象出生的年、月、日,其中年份用四位数字表示,年、月、日之间不用分隔符。顺序码表示同一地址码所标识的区域范围内,对同年、月、日出生的人员编定的顺序号。顺序码的奇数分给男性,偶数分给女性。校验码是根据前面十七位数字码,按照ISO   7064:1983.MOD   11-2校验码计算出来的检验码。下面举例说明该计算方法。     
        
          15位的身份证编码首先把出生年扩展为4位,简单的就是增加一个19,但是这对于1900年出生的人不使用(这样的寿星不多了)   
        
          某男性公民身份号码本体码为34052419800101001,首先按照公式⑴计算:     
        
          ∑(ai×Wi)(mod   11)……………………………………(1)     
        
          公式(1)中:   
          i----表示号码字符从由至左包括校验码在内的位置序号;   
          ai----表示第i位置上的号码字符值;   
          Wi----示第i位置上的加权因子,其数值依据公式Wi=2(n-1)(mod   11)计算得出。     
        
          i   18   17   16   15   14   13   12   11   10   9   8   7   6   5   4   3   2   1     
        
          ai   3   4   0   5   2   4   1   9   8   0   0   1   0   1   0   0   1   a1     
        
          Wi   7   9   10   5   8   4   2   1   6   3   7   9   10   5   8   4   2   1     
        
          ai×Wi   21   36   0   25   16   16   2   9   48   0   0   9   0   5   0   0   2   a1     
        
          根据公式(1)进行计算:     
        
          ∑(ai×Wi)   =(21+36+0+25+16+16+2+9+48++0+0+9+0+5+0+0+2)   =   189     
        
          189   ÷   11   =   17   +   2/11     
        
          ∑(ai×Wi)(mod   11)   =   2     
        
          然后根据计算的结果,从下面的表中查出相应的校验码,其中X表示计算结果为10:     
        
          ∑(ai×WI)(mod   11)   0   1   2   3   4   5   6   7   8   9   10     
          校验码字符值ai   1   0   X   9   8   7   6   5   4   3   2   
      根据上表,查出计算结果为2的校验码为所以该人员的公民身份号码应该为   34052419800101001X   
      

  5.   

    这个包  com.ulic  在哪儿?
      

  6.   

    这个是18位的,,改下就OK了,关键是知道规则"[0-9]{6}19[0-9]{2}[01][0-9][0123][0-9][0-9]{2}[0-9]([0-9]|x)"18位身份证号码验证
    前6位:
    [0-9]{6} :省区县编号 6位0到9数字7至14位
    19[0-9]{2}: 年份,19XX年
    [01][0-9]:月份,月份十位部分是0或1.个位是0-9的数字
    [0123][0-9]:日,日十位数年是0或1或2或3,个位是0-9的数字15到18,后四位
    [0-9]{3}([0-9]|x): 前三位任意数字后一位是一位数字或x
      

  7.   


    用这个方法:
    matches
    public boolean matches(String regex)通知此字符串是否匹配给定的正则表达式。 
    此方法调用的 str.matches(regex) 形式与以下表达式产生完全相同的结果: Pattern.matches(regex, str)参数:
    regex - 用来匹配此字符串的正则表达式 
    返回:
    当且仅当此字符串匹配给定的正则表达式时,才返回 true 
    抛出: 
    PatternSyntaxException - 如果正则表达式的语法无效
    从以下版本开始: 
    1.4 
    另请参见:
    Pattern
      

  8.   

    http://epasser.aydc.com.cn/article/adp/2/content14477.html   里面有详细的说明
      

  9.   

    4楼的程序不对,例如身份证是"空字第121730210597"或"空字第12173021059X",程序认为是有效身份证
    所以先要判断是否包含双字节字符,判断长度用length()和getBytes.length都不行