Regular Expressions Java Tutorial

Character classes specify a list of possible characters that can match any single character in the string you want to match.
Using the expression [^012], any single digit except for 0, 1, and 2 is matched.
You can specify character ranges using the dash.
The character class [a–z] matches any single lowercase letter.
[^a–z] matches any character except a lowercase letter.
[0–9] to match a single digit.
[0–3] to match a 0, 1, 2, or 3.
[a–zA–Z] to match any single letter.
Character Class Meta-CharacterMatches
.Any single character
\dA digit [0–9]
\DA nondigit [^0–9]
\sA whitespace character [ \t\n\x0B\f\r]
\SA nonwhitespace character [^\s]
\wA word character [a–zA–Z_0–9]
\WA nonword character [^\w]