1 String s_age="34"; 2 String s_birth="1989-10-01"; 3 String s_secur15="411313891001001"; 4 String s_secur18="411313198910010017"; 5 String regEx_age ="[0-9]{1,3}"; //年龄 6 String regEx_birth ="[0-9]d{4}/-[0-9]{1}[0-2]{1}/-[0-9]{1}[0-2]{1}";//出生年月yyyy-MM-dd 7 String regEx_secur15 ="[0-9]{14}[0-9a-zA-Z]";//15位身份证 8 String regEx_secur18 ="[0-9]{17}[0-9a-zA-Z]";//18位身份证 9 Pattern pat_age = Pattern.compile(regEx_age); 10 Pattern pat_birth = Pattern.compile(regEx_birth); 11 Pattern pat_secur15 = Pattern.compile(regEx_secur15); 12 Pattern pat_secur18 = Pattern.compile(regEx_secur18); 13 Matcher mat = pat.matcher(s_age); 14 boolean rs = mat.find();