一、代码
@Testpublic void test(){//包含数字、大小写字母,长度10-20位 String regular = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{10,20}$";String example1 = "1234567891";System.out.println(example1.matches(regular)); //falseString example2 = "abcdefghjkl";System.out.println(example2.matches(regular)); //falseString example3 = "ABCDEFGHJKL";System.out.println(example3.matches(regular)); //falseString example4 = "1abAb1234564646";System.out.println(example4.matches(regular)); //true}
二、测试
三、其他正则匹配
常用正则表达式-事半功倍利器_1-31的正则表达式_好奇的菜鸟的博客-CSDN博客