Java - Predefined Character Classes


Some frequently used predefined character classes are listed in the following Table.

Predefined Character Classes
Any character
may or may not match line terminators.
A digit.
Same as [0-9]
A non-digit.
Same as [^0-9]
A whitespace character.
Same as [ \t\n\x0B\f\r]. The list includes a space, a tab, a new line, a vertical tab, a form feed, and a carriage return characters.
A non-whitespace character.
Same as [^\s]
A word character.
Same as [a-zA-Z_0-9]. The list includes lowercase letters, uppercase letter, underscore, and decimal digits.
A non-word character.
Same as [^\w]