Character classes

Character Classes

This is an alternate method of specifying a range of characters to match. With a “character class”, also called “character set”, you can tell the regex engine to match only one out of several characters.

Following are the character classes.


It matches alphabetic or numeric characters and equivalent to A-Za-z0-9.


It matches alphabetic characters and equivalent to A-Za-z.


It matches lowercase alphabetic characters and equivalent to a-z.


It matches uppercase alphabetic characters and equivalent to A-Z.


It matches hexadecimal digits and equivalent to 0-9A-Fa-f.


It matches digits and equivalent to 0-9.


It matches a space or a tab.


It matches control characters.

[:print:] [:graph:]

Matches characters in the range of ASCII 32 – 126.


It matches black space characters (space and horizontal tab).



Learn Technology

%d bloggers like this: