Regex (regular expression) password check with Java
Our String is
aaaaaZZaa44
and with the regular
((?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{6,})
we check if our password contains at least one digit, one upper and lower case.
we also check the length of the password, if its greater than 6.
import java.util.regex.*;
public class RegexPwdCheck {
public static void main(String[] args) {
String passwd = "aaaaaZZaa44";
String pattern = "((?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{6,})";
System.out.println(passwd.matches(pattern));
}
}
Similar entries
- E-Mail validation with Java and regular expressions (regex)
- Check password strength / safety with PHP and Regex
- How to select a secure password for your online logins
- Replace string in big database or large text file
- Check password safety with JavaScript while typing
- Mysql: update weight by an auto-incremented string created on the fly
- Invalid utf8 character string
- #1045 Cannot log in to the MySQL server (PhpMyAdmin 2.4.8)
- Black-White theme for Notepad++ (for Programmers)
- Howto protect admin.php / login.php with htaccess password
- Mysql replace with regexp
- Search only in .php files under linux
- Filezilla and plain-text clear, unsecure password storage
- [Howto Fix] Table './eximstats/sends' is marked as crashed and should be repaired
- Include both php/ html files, catch & assign output to a string variable
- [warn] [client 1.2.3.4] mod_fcgid: HTTP request length 137744 (so far) exceeds MaxRequestLen (131072), referer
- Configure phpMyAdmin to login automagicly without prompted for username and password
- Search in text files recursively with PHP - Grep
- Backup all MySQL databases automagicly with the PHP admin script
- How2 install Solaris, Android and Mac on VMware?

Comments
Post new comment