📜  java 字符串长度验证正则表达式 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:18.238000             🧑  作者: Mango

代码示例1
//Password validation example
public static Boolean validPassword(String password) throws IllegalArgumentException {
   if (!password.matches("\\w{6,}"))/*Or '(password.matches("\\w{6,}") == false)'*/ {
      throw new IllegalArgumentException("Password must be at least 6 characters long.");
   
   //'("\\w{int}")' => Must be int characters long.
   //'("\\w{int,}")' => Must be AT LEAST int characters long and can be longer.
   //'("\\w{int1,int2}")' => Must be BETWEEN int1 AND int2 characters long.
   
   }
   return true;
}