skipnothing/Regex Engines

Quantifiers & Groups

.+ reads like "grab a few characters." Aim it at <EM>first</EM> and it swallows everything to the line's end, then hands characters back one by one until the closing > finally has something to match.

  • ▸ab+ repeats the b, never the ab: the + reaches back to one token, no further.
  • ▸<.+> does not grab a little. It grabs the whole line, then hands characters back until > can match.
  • ▸One ? in <.+?> flips the match's growth: minimum outward, not maximum inward.
BUILDS ON
01

Repeat the Token to the Left

Every operator so far has matched a fixed amount: a literal takes one character, a class takes one, an anchor takes none. A quantifier sets the count. Write a token, put + after it, and the + means "one or more of the thing on my left." The load-bearing word is *left*: a quantifier reaches back to exactly one token, the single one immediately before it, and nothing else.

Run go+gle. The + sits on the o, so it matches gogle, google, gooogle, any run with one or more o wedged between g and gle. The surrounding letters are untouched; only the o repeats.

Four quantifiers cover the everyday counts. ? means zero or one, so colou?r matches both color and colour. * means zero or more. + means one or more. {n,m} names an exact range: \d{4} matches four digits in a row, a year like 2026, and \d{2,4} allows two to four.

This is why ab+ catches people out: the + owns only the b, so it matches ab, abb, abbb, never abab. To repeat the whole pair, you wrap it in parentheses: (ab)+.

A QUANTIFIER REACHES BACK TO ONE TOKEN

Keep going, sign up to unlock the rest

4 more parts in this topic, plus 11+ more topics in Regex Engines.

Sign up, it's freeSee the full Regex Engines