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: it matches any single character except a line break, and does not care which one.

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

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.

EXERCISE

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