REGEX character classes
We'll cover the following
Regex character class can make our life easy, as it makes one small sequence of characters match a larger set of characters. However, character classes can only be used within bracket expressions. For example, [[:upper:]xy]
matches all the uppercase letters and lowercase "x"
and "y"
.
Char Class | Description |
---|---|
[:alnum:] |
alphanumeric characters [A-Za-z0-9] |
[:lower:] |
lowercase letters [a-z] |
[:upper:] |
uppercase letters [a-z] |
[:digit:] |
digits [0-9] |
[:blank:] |
Space and tab [ \t] |
[:space:] |
Space [ ] |
[:punct:] |
punctuation characters e.g., [][!"#$%&'()*+,./:;<=>?@\^_{}~-] |
Example:
Get hands-on with 1400+ tech skills courses.