Character Class

noun

say it: “KAIR-ik-ter KLASS” /ˈkɛrɪktər ˈklæs/

A list of characters in square brackets in a pattern, such as [0-9], that matches any one character from the list.

What is a character class in a pattern?

A character class is a list of characters in square brackets that matches any one character from the list. [0-9] is any one digit, [aeiou] any one vowel, and [A-Z] any one capital letter. Each class stands for exactly one character, so a phone number needs one class per digit.

grep -r '[0-9][0-9][0-9].[0-9][0-9][0-9][0-9]' notes

In a sentence

  • “The character class [0-9] matches any one digit, so a phone number needs one for each digit.”
  • “Sam wrote the character class [aeiou] to match any one vowel.”

Level: Apprentice · More Unix terms at this level

Updated