A character class is a group of characters inside of a pair of square brackets. A character class matches exactly one character. It matches one of the characters inside of the brackets.
Example: [LOST] matches the letter L, the letter O, the letter S, or the letter T.
Range of charactersEdit
Use the dash (-) to indicate a range. Example: [L-T] matches every letter from L to T. [4L-T8] matches every letter from L to T, the number 4, or the number 8.
Negated character classEdit
Example: [^LOST] matches any character that is not L, O, S or T.
A negated character class is still a character class, which means that it still needs to match exactly one character.
Meta-characters inside of a character class and outside of a character class have different meanings. For example, period (.) is a meta-character outside of a character class, and is a normal, literal character inside of the square brackets.
Alternations can be used instead to match the same thing, if there aren't any ranges or negation involved. For example, [LOST] can be written as L|O|S|T.
The character class [0-9] can be written as \d.