A
Adam Lipscombe
Folks,
I am struggling with regular expressions to validate passwords in Struts 1.3.
At this stage I simply want to check that there are no repeating characters in the string.
My code is:
String password = "123456"; // Should pass
Pattern p = Pattern.compile("^(?!.*(.)\\1{1})");
Matcher m = p.oatcher(password);
if (true == m.lookingAt())
{
// Error = repeating char
System.out.println("repeating chars");
}
Is this the correct approach?
Can anyone suggest a suitable expression - the one I used does not work.
Later I want to check for at least one uppercase letter, one lowercase letter and a digit.
TIA - Adam
I am struggling with regular expressions to validate passwords in Struts 1.3.
At this stage I simply want to check that there are no repeating characters in the string.
My code is:
String password = "123456"; // Should pass
Pattern p = Pattern.compile("^(?!.*(.)\\1{1})");
Matcher m = p.oatcher(password);
if (true == m.lookingAt())
{
// Error = repeating char
System.out.println("repeating chars");
}
Is this the correct approach?
Can anyone suggest a suitable expression - the one I used does not work.
Later I want to check for at least one uppercase letter, one lowercase letter and a digit.
TIA - Adam