Another thing about quantification and quoting:
An emtpy quoting follwed by a quanfitier is illegal:
PCRE2 version 10.45-DEV 2024-06-09 (8-bit)
/\Q\E{2,}/debug
Failed: error 109 at offset 7: quantifier does not follow a repeatable item
But if it is inside a group it is allowed:
PCRE2 version 10.45-DEV 2024-06-09 (8-bit)
/(\Q\E){2,}/debug
------------------------------------------------------------------
0 19 Bra
3 5 CBra 1
8 5 Ket
11 5 SCBra 1
16 5 KetRmax
19 19 Ket
22 End
------------------------------------------------------------------
Capture group count = 1
May match empty string
Subject length lower bound = 0
aa
0:
1:
If something precedes the empty quoting it is also ok:
PCRE2 version 10.45-DEV 2024-06-09 (8-bit)
/(a|b)\Q\E{2,}+/debug
------------------------------------------------------------------
0 39 Bra
3 33 Once
6 7 CBra 1
11 a
13 5 Alt
16 b
18 12 Ket
21 7 CBraPos 1
26 a
28 5 Alt
31 b
33 12 KetRpos
36 33 Ket
39 39 Ket
42 End
------------------------------------------------------------------
Capture group count = 1
Starting code units: a b
Subject length lower bound = 2
aa
0: aa
1: a
Sorry for lengthy posts about these corner cases, I realize there is a lot of work to parse this 100% accurately. I try to make my parser forgiving in uncertain cases, and then one can always impose rules on top of the parsed result if necessary. I think I can safely treat empty quotings as comments (same as isolated \E's).
Best regards,
David
lördag 10 augusti 2024 kl. 10:08:24 UTC+2 skrev Philip Hazel: