Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be a simple regular expression for password check during signup?

What I want to do is just check when the user is signing up that whether the password entered is at least 6 characters and has no space in it. Thats pretty much it. What would be a regex that I could use in Java Pattern Matcher classes for this purpose?

Thanks for your help guys.

like image 910
Aakash Avatar asked Dec 18 '25 04:12

Aakash


1 Answers

Why do you want to use a regex?

public boolean isPasswordValid( String password )
{
    return ((password.length() >= 6) && (!password.contains(" "));
}
like image 164
Reese Moore Avatar answered Dec 20 '25 22:12

Reese Moore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!