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] |
Leave a Reply