Step: Literal characters

Literal characters

A regex is a search pattern. The simplest pattern is literal text — it matches exactly those characters, wherever they appear.

Why it matters: most real patterns are mostly literal text with a few special characters mixed in. Matching is global here, so every occurrence is returned, not just the first.

Example: the pattern cat finds the three letters c-a-t in order.

Your turn: match every at in the sentence.

Pitfall: regex is case-sensitive by default — cat will not match Cat. (Add the i flag to ignore case: /cat/i.)

Input:
The cat sat on the mat.
Expected:
[
  "at",
  "at",
  "at"
]
Step 1 of 11