Matching POSIX Character Classes


Advertisements

Following are various examples of matching POSIX character classes using regular expression in java.

Sr.No Construct & Matches
1 \p{Lower}

A lower-case alphabetic character: [a-z].

2 \p{Upper}

An upper-case alphabetic character:[A-Z].

3 \p{ASCII}

All ASCII:[\x00-\x7F].

4 \p{Alpha}

An alphabetic character:[\p{Lower}\p{Upper}].

5 \p{Digit}

A decimal digit: [0-9].

6 \p{Alnum}

An alphanumeric character:[\p{Alpha}\p{Digit}].

7 \p{Punct}

Punctuation: One of !"#$%&'()*+,-./:;<=>?@[\]^_>{|}<.

8 \p{Graph}

A visible character: [\p{Alnum}\p{Punct}].

9 \p{Print}

A printable character: [\p{Graph}\x20].

10 \p{Blank}

A space or a tab: [ \t].

11 \p{XDigit}

A hexadecimal digit: [0-9a-fA-F].

12 \p{Space}

A whitespace character: [ \t\n\x0B\f\r].

Advertisements