### Question:
RegexUtil { public static boolean isIdentityNumber(String num) { String area = "(1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5]|82|[7-9]1)[0-9]{4}"; String year = "(19|20)[0-9]{2}"; String mmdd = "(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8])))"; String yearMmdd = year + mmdd; String leapYear = "((19|20)(0[48]|[2468][048]|[13579][26])|2000)"; String leapMmdd = "0229"; String leapyearMmdd = leapYear + leapMmdd; String mantissa = "[0-9]{3}[0-9Xx]"; String regex = String.format("^%s((%s)|(%s))%s$", area, yearMmdd, leapyearMmdd, mantissa); num = num.replace(" ", ""); if (!num.matches(regex)) return false; int summary = 0 + (Integer.valueOf(num.substring(0, 1)) + Integer.valueOf(num.substring(10, 11))) * 7 + (Integer.valueOf(num.substring(1, 2)) + Integer.valueOf(num.substring(11, 12))) * 9 + (Integer.valueOf(num.substring(2, 3)) + Integer.valueOf(num.substring(12, 13))) * 10 + (Integer.valueOf(num.substring(3, 4)) + Integer.valueOf(num.substring(13, 14))) * 5 + (Integer.valueOf(num.substring(4, 5)) + Integer.valueOf(num.substring(14, 15))) * 8 + (Integer.valueOf(num.substring(5, 6)) + Integer.valueOf(num.substring(15, 16))) * 4 + (Integer.valueOf(num.substring(6, 7)) + Integer.valueOf(num.substring(16, 17))) * 2 + Integer.valueOf(num.substring(7, 8)) *1 + Integer.valueOf(num.substring(8, 9)) * 6 + Integer.valueOf(num.substring(9, 10)) * 3; int remainder = summary % 11; String check = "10X98765432".substring(remainder, remainder + 1); return check.equals(num.substring(17, 18)); }  static boolean isIdentityNumber(String num); static boolean isCellphoneNumber(String num); static boolean isCellphoneNumber(String num, boolean virtual); static boolean isPhoneNumber(String num); static boolean isAuthCode(String num); static boolean isAuthCode(String num, int min, int max); static boolean isName(String name); static boolean isVehicleLicence(String license); static boolean isEmail(String email); static boolean isBankCard(String card); static boolean isLowerMoney(String money); static boolean isInteger(String integer, long min, long max); static boolean isPassword(String password); static boolean isComplexPassword(String password); static boolean isIpAddress(String address); static boolean isIp4Address(String address); static boolean isIp6Address(String address);  }### Answer:
@Test public void isIdentityNumber() { assertTrue(RegexUtil.isIdentityNumber("510101199001011119")); assertFalse(RegexUtil.isIdentityNumber("510101199001011110")); }