Predefined Character Classes
The Pattern
API contains a number of useful predefined character classes, which offer convenient shorthands for commonly used regular expressions:
. |
Any character (may or may not match line terminators) |
\d |
A digit: [0-9] |
\D |
A non-digit: [^0-9] |
\s |
A whitespace character: [ \t\n\x0B\f\r] |
\S |
A non-whitespace character: [^\s] |
\w |
A word character: [a-zA-Z_0-9] |
\W |
A non-word character: [^\w] |
https://docs.oracle.com/javase/tutorial/essential/regex/pre_char_classes.html