Context: regular expressions, regexp, regex
In regular expressions (or regexp, or regex)pattern matching syntax, a character class is a series of characters enclosed by brackets, such as [A-Ca-c]. A character class matches any of the characters within that class. Thus the above example would match any of: A, B, C, a, b, c.
To specify a character class, simply enclose the characters you want to match in brackets. Denote ranges of characters (such as A-C above) with a hyphen. If you want to match a hyphen, place it as the first character of the class. If you want to match a right bracket, specify it as \].
You can negate a character class by placing a caret (^) character as the first character of the class. Thus [^A-Ca-c] would match all characters but A, B, C, a, b, c.
All other special characters within the regexp syntax lose their special meaning in a character class.