3 chars · 1 line
8 chars · 1 line
3 chars · 1 line
8 chars · 1 line
Regex quantifier behavior
The pattern \d* is valid and means zero or more digits. On abc, JavaScript can satisfy it with zero digits at the start, so test() returns Match even though the input contains no digit. This tool is free to use. No account or payment is required.
Last updated
A successful zero-length match is still a match. This matters in validation and scanning patterns where an apparently specific token can become optional because of *.
Require at least one digit instead of allowing zero digits.
\d*\d+Common questions
Because * allows zero digits, and a zero-length match satisfies the regex.
No. + requires at least one digit.
They can if a manual exec loop never advances. VetaTool's Match All scanner explicitly advances after empty matches.
Debugging a specific Regex issue? Browse Regex troubleshooting.