CHARACTER CLASSES

Ranges

A dash inside brackets spans a range: [0-9], [a-z], [a-f].

Writing every character out gets old. [0123456789] is just [0-9]. A dash between two characters means the whole run in character-code order: [a-z] is every lowercase letter, so in "Cat" it matches a and t and skips the capital C.

Combine ranges and single characters freely. [a-f0-5] is two ranges in one set: any of a-f or any of 0-5. [A-Za-z_] matches one letter of either case or an underscore - the classic identifier start.

PRACTICE - 2 DRILLS 0/2 DONE
DRILL 1/2

Match every single digit.

/ /
room 4, floor 7
must match: "4" "7"
gate B12
must match: "1" "2"
no digits at all
must match nothing
DRILL 2/2- Uppercase letters

Match every uppercase letter.

/ /
Hello World
must match: "H" "W"
iPhone XR
must match: "P" "X" "R"
all lowercase
must match nothing