From the Java documentation:
The match method attempts to match the entire input sequence with the pattern.
Your regular expression matches a single digit, not a number. Add +after \\din line with other numbers:
private static final String NUMBER_PATTERN = "\\d+";
As an additional note, you can combine initialization and template declaration, which makes the constructor unnecessary:
Pattern pattern = Pattern.compile(NUMBER_PATTERN);
source
share