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?
Asked
Active
Viewed 104 times
0

jecolon
- 188
- 1
- 7
-
Don't it then just matches literal `{`? https://regex101.com/r/PwG9he/1 Try regex e.g. `Product\d{12312312342342342}` – Justinas Apr 13 '22 at 15:18
-
@Justinas : yes it does, but isn't that a problematic fallback mechanism, making it hard to find erroneous patterns? If I wanted to match the literal `{` I should be forced to use `\{` as with other special characters. – jecolon Apr 13 '22 at 15:27
-
1If there is no matching closing `}` then it's literal string. – Justinas Apr 13 '22 at 16:59
1 Answers
0
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.

jecolon
- 188
- 1
- 7