I want to make a regular expression to the following string :
String s = "fdrt45B45"; // s is a password (just an example) with only
// letters and digits(must have letters and digits)
I tried with this pattern:
String pattern= "^(\\w{1,}|\\d{1,})$"; //but it doesn't work
I want to get a not match if my password doesn't contains letters or digits and a match if its contains both.
I know that: \w is a word character: [a-zA-Z_0-9]
and \d is a digit: [0-9]
, but i can not mix \w and \d
to get what i want. Any help or tips is very appreciated for a newbie.