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

Put a carat (^) immediately after the opening square bracket ([) to negate the character class. A negated character class matches any character that is not included in the group.

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-character usageEdit

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.

Equivalent methodEdit

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.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.