Javaregex 简明教程

Matching POSIX Character Classes

以下是使用正则表达式在 Java 中匹配 POSIX 字符类的各种示例。

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

\pA space or a tab: [ \t].

11

\p{XDigit}A hexadecimal digit: [0-9a-fA-F].

12