Why does this pattern not produce an error?

179 Views Asked by At

Compiled PCRE2 10.39 from source on aarch64 (Apple M1). If I use the pattern Product\d{2,} it compiles and matches correctly, but if I instead use the pattern Product\d{2 it doesn't produce any compile error (pcre2_compile) but rather just doesn't match anything when calling pcre2_match. Is this by design? Can it be configured to produce an error instead?

1

There are 1 best solutions below

0
On

In line with @Justinas' comments, I found the answer in the PCRE2 Spec https://www.pcre.org/current/doc/html/pcre2pattern.html#SEC17 :

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.