I have to create a Regex for password validation which match
eg.
abcdABCD1234$%^
password must contains atleast two lowercase,two uppercase, two numeric and two special character. But they can give more than this criteria
Note- pattern should be inorder.
String pattern="(?=.*[a-z]{2,})(?=.*[A-Z]{2,})(?=.*[0-9]{2,})(?=.*[@#$%&]{2,})";
it is working for me but it is not checking order
means
AB uppercase or anycharacter should not come before ab (lowercase).
Does it clear for u.
String minNum="4";
String max="20";
String REGEX="(^(?!.*(d))(?=.*[a-z]{3,})(?=.*[A-Z]{2,})(?=.*[0-9]{3,})(?=.[@#$%&*><?+]{2,})^(?!.*(#r)).{"+minNum+","+max+"})";
//String regex="(?=.*[a-z]{2,})(?=.*[A-Z]{2,})(?=.*[0-9]{2,})(?=.*[@#$%&]{2,})";
String INPUT ="acABC1333323@#";
Pattern p = Pattern.compile(REGEX);
Matcher m = p.matcher(INPUT);
System.out.println(m.matches());
it is working correctly but when i am changing password
“ABac1333323@#”; it also matches but it is in correct according to my requirement, because AB is first order.
I think this is what you want
It matches
abcdABCD1234$%^andabABcdCD1234$%^It does not match
ABababcdCD1234$%^orABac1333323@#For two or more lower case followed by two or more upper case followed by two or more digits followed by two or more special characters, use :