I am creating an identification window with login and username for JavaFX, and I am using regex to make sure that the password contains at least one special character and one digit.
This is the regular expression I'm using
newValue.matches("*\\d+.*\\W+.*")
It works on testing sites online however I am getting and error while I enter any input in the textfield. Here is the segment of code I am using:
public void progressBarHandler() {
login.textProperty().addListener((observable, oldValue, newValue) -> {
if(newValue.matches("*\\d+.*\\W+.*")) {
passState.textProperty().set("Bad");
}
else passState.textProperty().set("Ok");
});
}
Whenever I run the code and I write something in the textfield login I get this error:
Exception in thread "JavaFX Application Thread" java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0