简体   繁体   中英

Why does this pattern not produce an error?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM