Chapter 3 of 10All chapters
Chapter 3 of 10
Quantifiers
How many times.
The three plus one
An asterisk means zero or more, a plus means one or more, a question mark means zero or one, and braces give an exact count or range.
- a{2,4} matches two to four a characters.
- Zero-or-more can match nothing at all, which is a common source of empty matches.
Greedy and lazy
Quantifiers take as much as they can, then give characters back until the rest matches. Adding a question mark makes them lazy and take as little as possible, which is why .*? is everywhere in tag matching.