4.5 Character Classes

Character classes are enclosed in brackets and specify a set of characters to match. Within the brackets, single characters or ranges specified as a low character, a dash and a high character, can be specified. For example [a-z0] specifies all characters from "a" to "z" and the character "0". Escape characters can be used within character classes. The inversion of a character class is specified by using the "^" character immediately after the open brace: [^a-z] specifies all characters except those from "a" to "z". In addition the following names can be used within the character class (ie: "[[:alpha:]0]" for all the alphabet and the "0" character):

Class Name  Description 
[:alnum:] Alphabet and number characters.
[:alpha:] Alphabet characters
[:blank:] Tab and space.
[:cntrl:] Control characters.
[:digit:] Number characters.
[:graph:] Characters that show up on the screen.
[:lower:] Lowercase alphabet characters.
[:print:] Characters that show up on the screen and space.
[:punct:] Punctuation characters.
[:space:] Any form of formatting character (spaces, newlines, ...).
[:upper:] Uppercase alphabet characters.
[:xdigit:] Hexadecimal number characters.

See the PyGgy Home Page.