Regular Expressions (Regex) Character Classes Cheat Sheet

POSIX Character Classes for Regular Expressions & their meanings

Character Class Meaning
[:alpha:] Any letter, [A-Za-z]
[:upper:] Any uppercase letter, [A-Z]
[:lower:] Any lowercase letter, [a-z]
[:digit:] Any digit, [0-9]
[:alnum:] Any alphanumeric character, [A-Za-z0-9]
[:xdigit:] Any hexadecimal digit, [0-9A-Fa-f]
[:space:] A tab, new line, vertical tab, form feed, carriage return, or space
[:blank:] A space or a tab.
[:print:] Any printable character
[:punct:] Any punctuation character: ! ' # S % & ' ( ) * + , - . / : ; < = > ? @ [ / ] ^ _ { | } ~
[:graph:] Any character defined as a printable character except those defined as part of the space character class
[:word:] Continuous string of alphanumeric characters and underscores.
[:ascii:] ASCII characters, in the range: 0-127
[:cntrl:] Any character not part of the character classes: [:upper:], [:lower:], [:alpha:], [:digit:], [:punct:], [:graph:], [:print:], [:xdigit:]


See also: Regex Cheat Sheet

Copyright © 2008 Peter Freitag (http://www.petefreitag.com/), All Rights Reserved.
This document may be printed freely as long as this notice stays intact.