Predefined Character Classes
The Pattern API contains a number of useful predefined character classes, which offer convenient shorthands for commonly used regular expressions:
| Construct | Description |
|---|---|
. | Any character (may or may not match line terminators) |
\d | A digit: [0-9] |
\D | A non-digit: [^0-9] |
\s | A whitespace character: [ \t\n\x0B\f\r] |
\S | A non-whitespace character: [^\s] |
\w | A word character: [a-zA-Z_0-9] |
\W | A non-word character: [^\w] |
https://docs.oracle.com/javase/tutorial/essential/regex/pre_char_classes.html
本文介绍了Java中Pattern API提供的预定义字符类,包括常用正则表达式的便捷缩写,如匹配任意字符、数字、空白字符等,并提供详细的构造方法及描述。
447





