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 theb, never theab: 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.
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)+.