From deb026c631777e730d798740fc992bd4982eb4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=9A=E6=96=87?= <15549487+FX_YBW@user.noreply.gitee.com> Date: Wed, 8 Oct 2025 23:43:43 +0800 Subject: [PATCH] =?UTF-8?q?v1.2=20=E7=99=BB=E5=BD=95=E3=80=81=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=8E=A5=E5=8F=A3=E4=B9=A6=E5=86=99=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ybw/mathapp/util/Register.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ybw/mathapp/util/Register.java b/src/main/java/com/ybw/mathapp/util/Register.java index 1dad672..4ad06cd 100644 --- a/src/main/java/com/ybw/mathapp/util/Register.java +++ b/src/main/java/com/ybw/mathapp/util/Register.java @@ -16,26 +16,28 @@ public class Register { /** * 前端接口-密码格式验证 * @param password1 第一次输入的密码 - * @param password2 第二次输入的密码 * @return true表示符合要求,false表示不符合 */ - public static boolean isVaildPassword(String password1, String password2) { - if (password1 == null || password1.length() < 6 || password1.length() > 10) { - return false; - } - + public static boolean isVaildPassword(String password1) { // 使用正则表达式验证:长度6-10,只包含字母数字,且包含大小写字母和数字 String regex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{6,10}$"; if (!Pattern.matches(regex, password1)) { return false; } + return true; + } - System.out.print("请再次输入密码: "); + /** + * 前端接口-两次密码匹配 + * @param password1 第一次输入的密码 + * @param password2 第二次输入的密码 + * @return true表示符合要求,false表示不符合 + */ + public static boolean isEqualPassword(String password1, String password2) { if (!password1.equals(password2)) { System.out.println("两次输入的密码不一致!"); return false; } return true; } - }