Sign in Start free

3Character classes

Square brackets match one character out of a set: [aeiou] is any vowel.

A character class (or set) in square brackets matches one character that is in the list. gr[ae]y matches both gray and grey, but not graey – the class stands for a single character.

Inside a class most metacharacters lose their special meaning: [.?*] matches a dot, a question mark or a star. Only ], \, ^ (at the start) and - (between two characters) are special there.

Exercises