use regex in if statement java
Pattern p = Pattern.compile("a*b");
Matcher m = p.matcher("aaaaab");
boolean b = m.matches();
use regex in if statement java
Pattern p = Pattern.compile("a*b");
Matcher m = p.matcher("aaaaab");
boolean b = m.matches();
java string length validation regex
//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;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us