Posts

Showing posts with the label password check

[JAVA] password Regular expression Only 9 digits including letters + special characters + numbers

Image
<%@ page import = "java.util.regex.Matcher"%> <%@ page import = "java.util.regex.Pattern"%> if(passwordParam.equals("changePwToNew")) { boolean sameCharCheck = false; String checkStr = ""; String returnMsg = ""; //  Check the password format (more than 9 characters including English, special characters, and numbers) Pattern passPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)(?=.*[~!@#$%^*_+|<>?:{}])[A-Za-z\\d~!@#$%^*_+|<>?:{}]{9,}$"); Matcher passMatcher = passPattern.matcher(password); //  Check including 4 consecutive letters and numbers int o = 0; int d = 0; int p = 0; int n = 0; int limit = 4;     for (int i = 0; i < password.length(); i++) {         char tmpVal = password.charAt(i);         if (i > 0 && (p = o - tmpVal) > -2 && (n = p == d ? n + 1 : 0) > limit -3 ){         sameCharCheck = true; //  Has a cont...