Regex (regular expression) password check with Java

Submitted by rex on Wed, 04/29/2009 - 18:13

Our String is

and with the regular

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,})";


Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.