package com.dahe.mylibrary.utils;

import java.util.regex.Pattern;

public class PatternUtils {


    /**
     * 正则表达式:验证密码(包含大小写，数字，特殊字符，6-12位)
     */
//    public static final String REGEX_PASSWORD = "^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\\.])[0-9a-zA-Z!@#$%^&*,\\\\.]{6,12}$";
    public static final String REGEX_PASSWORD = "^(?=.*[0-9])(?=.*[a-z])(?=.*[!@#$%^&*,\\.])[0-9a-zA-Z!@#$%^&*,\\\\.]{6,12}$";
    public static final String REGEX_WORD = "^[A-Za-z]+$";

    /**
     * 校验密码
     *
     * @param password
     * @return 校验通过返回true，否则返回false
     */
    public static boolean isPassword(String password) {
        return Pattern.matches(REGEX_PASSWORD, password);
    }

    public static boolean isLetter(String password){
        return Pattern.matches(REGEX_WORD, password);
    }
}
