I’m trying the following segment to no avail:
public class test {
public static void main(String args[] ){
String password = "s8bgBQYPmUaNjkToXCJLAwAA";
System.out.println( Pattern.matches("[0-9]", password ));
}
}
I would expect that to work since I’m just looking for match of any digit to suffice the regex but my output always comes back false. Any help as to what I maybe missing or what could be wrong would be most appreciated.
You’re checking whether the whole string consists of one single digit. What you really mean is:
Adding the
.*to the start and end lets it match any number of other characters (.means “any character” and*means “any number of times”).