一、代码
@Test public void test(){ //包含数字、大小写字母,长度10-20位 String regular = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{10,20}$"; String example1 = "1234567891"; System.out.println(example1.matches(regular)); //false String example2 = "abcdefghjkl"; System.out.println(example2.matches(regular)); //false String example3 = "ABCDEFGHJKL"; System.out.println(example3.matches(regular)); //false String example4 = "1abAb1234564646"; System.out.println(example4.matches(regular)); //true }
二、测试