POSIX character classes

Java also supports many POSIX character classes for matching ASCII text. Here is the list:

POSIX Character Class Meaning Character Class
\p{ASCII} All ASCII characters [\x00-\x7F]
\p{Digit} Any digit [0-9]
\p{Lower} Lowercase alphabets [a-z]
\p{Upper} Uppercase alphabets [A-Z]
\p{Alpha} Any alphabet [\p{Lower}\p{Upper}]
\p{Alnum} Any alpha-numeric character [\p{Lower}p{Upper}\p{Digit}]
\p{Punct} A punctuation character [!"\#$%&'()*+,-./:;<=>?@\[\\\]^_`{|}~]
\p{Blank} Space or tab [ \t]
\p{Space} A whitespace character [ \t\n\x0B\f\r]
\p{Graph} A visible ASCII character [\p{Alnum}\p{Punct}]
\p{Print} A printable character [\p{Graph}\x20]
\p{Cntrl} A control character [\x00-\x1F\x7F]
\p{XDigit} ...

Get Java 9 Regular Expressions now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.