Regex Quantifiers
Repeat matchers: star, plus, ranges, and exact counts.
- regex quantifier
- greedy lazy
- match phone
- repeat pattern
- regex star plus
Regex Quantifiers
Repeat matchers: star, plus, ranges, and exact counts.
Commands
| Command | What it does |
|---|---|
a* | Zero or more |
a+ | One or more |
a? | Zero or one (optional) |
a{2,4} | Between 2 and 4 |
a{3} | Exactly 3 |
a{2,} | Two or more |
Example
^1[3-9]\d{9}$ # Chinese mobile number
FAQ
Why does my d-plus match too much?
It is greedy - pair it with boundaries or make it lazy when it over-matches.
How do I avoid catastrophic backtracking?
Use atomic groups or possessive quantifiers where supported, or narrow the repeated class.
常見問題
Why does my d-plus match too much?
It is greedy - pair it with boundaries or make it lazy when it over-matches.
How do I avoid catastrophic backtracking?
Use atomic groups or possessive quantifiers where supported, or narrow the repeated class.
Regex
Regex Basics
Literals, dots, and the core syntax every pattern builds on.
Regex Character Classes
Brackets, ranges, and negation for precise character sets.
Regex Anchors and Boundaries
Pin patterns to string, line, and word edges.
Regex Groups and Capturing
Capture, name, and backreference parts of a match.