BASICS

The dot

The dot matches any single character, exactly one.

h.t matches hat, hot, hit, and even "h t". The dot . is the first metacharacter - a character with a special job instead of standing for itself. It matches any single character except a line break, and does not care which one. To match a literal dot, you escape it.

Exactly one is the key. h.t does not match "heat" (two characters between h and t) or "ht" (zero).

The dot deliberately stops at line breaks. To let it span newlines too, add the s (dotAll) flag: /a.b/s. A portable alternative that needs no flag is [\s\S] - it comes naturally once character classes land. MDN: dotAll.

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

Match hat, hot, hit and any other h_t triple with one character in the middle.

/ /
the hat and the hot hit
must match: "hat" "hot" "hit"
h t
must match: "h t"
heat is not a triple
must match nothing
ht is too short
must match nothing
DRILL 2/2

Match big, bug, bog and any other b_g triple with exactly one character in the middle.

/ /
a big bug in the bag
must match: "big" "bug" "bag"
the bog by the log
must match: "bog"
beg pardon
must match: "beg"
no triple in this row
must match nothing