📅  最后修改于: 2020-11-14 10:19:56             🧑  作者: Mango
以下是在Java中使用正则表达式匹配字符类的各种示例。
Sr.No | Construct & Matches |
---|---|
1 | [abc]
a, b, or c (simple class). |
2 | [^abc]
Any character except a, b, or c (negation). |
3 | [a-zA-Z]
a through z or A through Z, inclusive (range). |
4 | [a-d[m-p]]
a through d, or m through p: [a-dm-p] (union). |
5 | [a-z&&[def]]
d, e, or f (intersection). |
6 | [a-z&&[^bc]]
a through z, except for b and c: [ad-z] (subtraction) |
7 | [a-z&&[^m-p]]
a through z, and not m through p: [a-lq-z](subtraction). |