Javaregex 简明教程

Matching Predefined Character Classes

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

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

Sr.No

Construct & Matches

1

.Any character (may or may not match line terminators).

2

\dA digit: [0-9].

3

\DA non-digit: [^0-9].

4

\sA whitespace character: [ \t\n\x0B\f\r]

5

\SA non-whitespace character: [^\s].

6

\wA word character: [a-zA-Z_0-9].

7

\WA non-word character: [^\w]