con il tool che ti dicevo mi da questi.. per non saper ne leggere ne scrivere te li posto, sono leggermente diversi.. ti riporto già le funzioni in java che restituiscono boolean
come puoi vedere non uso le classi pattern, ma uso il metodo match direttamente sulla stringa
codice:
// solo numerici
try {
boolean foundMatch = subjectString.matches("^\\d");
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
// alfanumerici
try {
boolean foundMatch = subjectString.matches("[^\\w]");
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
// true se trova caratteri diversi da digit, word, "." , " " e "_"
try {
boolean foundMatch = subjectString.matches("[^\\x00\\x2E\\x5F\\w\\s]");
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}