1、新建java代码,TestRegexp.java;
2、编码java代码,定义正则表达式,并编写测试代码;
//非空格字符组成的字符串,数字,大写字母,小写字母,特殊字符至少有 两种
String regex_11 = "^(?![A-Z]*$)(?![a-z]*$)(?![0-9]*$)(?![^a-zA-Z0-9]*$)\\S+$";
//测试1
System.out.println("abc :" + "abc".matches(regex_11));
System.out.println("abc@! :" + "abc@!".matches(regex_11));
System.out.println("abcA012 :" + "abcA012".matches(regex_11));
System.out.println("123 :" + "123".matches(regex_11));
System.out.println("ABC:" + "ABC".matches(regex_11));
System.out.println("ABCabc:" + "ABCabc".matches(regex_11));
3、窗口右击,选择执行java代码;
4、以各样例场景进行测试,查看执行结果;