因为eclipse很方便可以看到结果,这次就用了eclipse
1、名字匹配:如果名字有英文、符号、空格,都会被检验出不规范
/**
* 汉字的正则
*/
public static final String nickNameRegular = "^[\\u4E00-\\u9FA5]+$";
2、身份证校验
首先,创建工具类:IDCardUtils
import java.util.HashMap;
/**
* 身份证号码校验工具
*/
public class IDCardUtils {
private String _codeError;
// wi =2(n-1)(mod 11)
final int[] wi = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 };
// verify digit
final int[] vi = { 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 };
private int[] ai = new int[18];
private static String[] _areaCode = { "11", "12", "13", "14", "15", "21", "22", "23", "31", "32", "33", "34", "35",
"36", "37", "41", "42", "43", "44", "45", "46", "50", "51", "52", "53", "54", "61", "62", "63", "64", "65",
"71", "81", "82", "91" };
private static HashMap<String, Integer> dateMap;
private static HashMap<String, String> areaCodeMap;
static {
dateMap = new HashMap<String, Integer>();
dateMap.put("01", 31);
dateMap.put("02", null);
dateMap.put("03", 31);
dateMap.put("04", 30);
dateMap.put("05", 31);
dateMap.put("06", 30);
dateMap.put("07", 31);
dateMap.put("08", 31);
dateMap.put("09", 30);
dateMap.put("10", 31);
dateMap.put("11", 30);
dateMap.p