Answer the question
In order to leave comments, you need to log in
Strange regular expression behavior in php
php regex:
var_dump(preg_match("/^\d{0,10}$/","01234567")); => 1 (any number between zero and 10)
var_dump(preg_match("/^\d{,10}$/","01234567")); => 0 (any number between nothing and 10)
PHP doesn't understand incomplete quantifiers?
Answer the question
In order to leave comments, you need to log in
php.net/manual/en/regexp.reference.repetition.php
An opening curly bracket that appears in a position where a quantifier is not allowed, or one that does not match the syntax of a quantifier, is taken as a literal character.
For example, {,6} is not a quantifier, but a literal string of four characters
that is, if it is not valid, then it turns out to be useless ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question