| | |
| | | /** |
| | | * 验证密码 |
| | | * |
| | | * @param password 密码只能包含 字母 , 下划线 , 数字,长度必须在3 到 20 之间 |
| | | * @param password 密码只能包含 字母 , 下划线 , 数字,长度必须在6 到 20 之间 |
| | | * @return 证成功返回true,验证失败返回false |
| | | */ |
| | | public static boolean checkPassword(String password) { |
| | | String regex = "[0-9a-zA-Z_]\\w{2,19}"; |
| | | String regex = "[0-9a-zA-Z_]\\w{5,19}"; |
| | | return password.matches(regex); |
| | | } |
| | | |
| | |
| | | return Pattern.matches(regex, ipAddress); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 判断字符串是否包含中文 |
| | | * @Param: [str] |
| | | * @return: boolean |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/21 |
| | | */ |
| | | public static boolean checkContainChinese(String str){ |
| | | Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); |
| | | Matcher matcher = p.matcher(str); |
| | | return matcher.find(); |
| | | } |
| | | |
| | | } |