Regex Quantifier
Metacharacters like *, +, ?, {n,m} that specify repetition counts. They control how many times the preceding element appears.
Regex quantifiers are metacharacters that specify how many times the preceding pattern element should repeat. They include * (0 or more), + (1 or more), ? (0 or 1), and {n,m} (between n and m times).
By default, quantifiers are "greedy," matching as many characters as possible. Adding ? makes them "lazy," matching as few characters as possible. Detailed regex books explain the difference between greedy and lazy matching.
For example, /a{2,4}/ matches 2 to 4 consecutive a's, and /d+/ matches one or more digits. Quantifiers are also useful for validating character count limits.
Excessive nesting of quantifiers can cause catastrophic backtracking (ReDoS), so performance must be considered. Programming security guides cover ReDoS prevention.