Step: Character classes

Character classes

A character class [...] matches exactly one character from the set inside the brackets.

Why it matters: classes are more precise than . — you say exactly which characters are allowed.

Example: c[ou]t matches "cot" and "cut", but not "cat" or "cit".

Your turn: match only "cot" and "cut".

Pitfall: inside [...] most metacharacters lose their special meaning — [.] matches a literal dot, not any character.

Input:
cat cot cut cit
Expected:
[
  "cot",
  "cut"
]
Step 3 of 11