O'Reilly logo

Java 9 Regular Expressions by Anubhava Srivastava

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required