xref: /aosp_15_r20/external/pcre/testdata/testinput2 (revision 22dc650d8ae982c6770746019a6f94af92b0f024)
1# This set of tests is not Perl-compatible. It checks on special features
2# of PCRE2's API, error diagnostics, and the compiled code of some patterns.
3# It also checks the non-Perl syntax that PCRE2 supports (Python, .NET,
4# Oniguruma). There are also some tests where PCRE2 and Perl differ,
5# either because PCRE2 can't be compatible, or there is a possible Perl
6# bug.
7
8# NOTE: This is a non-UTF set of tests. When UTF support is needed, use
9# test 5.
10
11#forbid_utf
12#newline_default lf any anycrlf
13
14# Test binary zeroes in the pattern
15
16# /a\0B/ where 0 is a binary zero
17/61 5c 00 62/B,hex
18    a\x{0}b
19
20# /a0b/ where 0 is a binary zero
21/61 00 62/B,hex
22    a\x{0}b
23
24# /(?#B0C)DE/ where 0 is a binary zero
25/28 3f 23 42 00 43 29 44 45/B,hex
26    DE
27
28/(a)b|/I
29
30/abc/I
31    abc
32    defabc
33    abc\=anchored
34\= Expect no match
35    defabc\=anchored
36    ABC
37
38/^abc/I
39    abc
40    abc\=anchored
41\= Expect no match
42    defabc
43    defabc\=anchored
44
45/a+bc/I
46
47/a*bc/I
48
49/a{3}bc/I
50
51/(abc|a+z)/I
52
53/^abc$/I
54    abc
55\= Expect no match
56    def\nabc
57
58/ab\idef/
59
60/(?X)ab\idef/
61
62/x{5,4}/
63
64/z{65536}/
65
66/[abcd/
67
68/[\B]/B
69
70/[\R]/B
71
72/[\X]/B
73
74/[z-a]/
75
76/^*/
77
78/(abc/
79
80/(?# abc/
81
82/(?z)abc/
83
84/.*b/I
85
86/.*?b/I
87
88/cat|dog|elephant/I
89    this sentence eventually mentions a cat
90    this sentences rambles on and on for a while and then reaches elephant
91
92/cat|dog|elephant/I
93    this sentence eventually mentions a cat
94    this sentences rambles on and on for a while and then reaches elephant
95
96/cat|dog|elephant/Ii
97    this sentence eventually mentions a CAT cat
98    this sentences rambles on and on for a while to elephant ElePhant
99
100/a|[bcd]/I
101
102/(a|[^\dZ])/I
103
104/(a|b)*[\s]/I
105
106/(ab\2)/
107
108/{4,5}abc/
109
110/(a)(b)(c)\2/I
111    abcb
112    abcb\=ovector=0
113    abcb\=ovector=1
114    abcb\=ovector=2
115    abcb\=ovector=3
116    abcb\=ovector=4
117
118/(a)bc|(a)(b)\2/I
119    abc
120    abc\=ovector=0
121    abc\=ovector=1
122    abc\=ovector=2
123    aba
124    aba\=ovector=0
125    aba\=ovector=1
126    aba\=ovector=2
127    aba\=ovector=3
128    aba\=ovector=4
129
130/abc$/I,dollar_endonly
131    abc
132\= Expect no match
133    abc\n
134    abc\ndef
135
136/(a)(b)(c)(d)(e)\6/
137
138/the quick brown fox/I
139    the quick brown fox
140    this is a line with the quick brown fox
141
142/the quick brown fox/I,anchored
143    the quick brown fox
144\= Expect no match
145    this is a line with the quick brown fox
146
147/ab(?z)cd/
148
149/^abc|def/I
150    abcdef
151    abcdef\=notbol
152
153/.*((abc)$|(def))/I
154    defabc
155    defabc\=noteol
156
157/)/
158
159/a[]b/
160
161/[^aeiou ]{3,}/I
162    co-processors, and for
163
164/<.*>/I
165    abc<def>ghi<klm>nop
166
167/<.*?>/I
168    abc<def>ghi<klm>nop
169
170/<.*>/I,ungreedy
171    abc<def>ghi<klm>nop
172
173/(?U)<.*>/I
174    abc<def>ghi<klm>nop
175
176/<.*?>/I,ungreedy
177    abc<def>ghi<klm>nop
178
179/={3,}/I,ungreedy
180    abc========def
181
182/(?U)={3,}?/I
183    abc========def
184
185/(?<!bar|cattle)foo/I
186    foo
187    catfoo
188\= Expect no match
189    the barfoo
190    and cattlefoo
191
192/abc(?<=a+)b/
193
194/(?<!(foo)a\1)bar/
195
196/(?i)abc/I
197
198/(a|(?m)a)/I
199
200/(?i)^1234/I
201
202/(^b|(?i)^d)/I
203
204/(?s).*/I
205
206/[abcd]/I
207
208/(?i)[abcd]/I
209
210/(?m)[xy]|(b|c)/I
211
212/(^a|^b)/Im
213
214/(?i)(^a|^b)/Im
215
216/(a)(?(1)a|b|c)/
217
218/(?(?=a)a|b|c)/
219
220/(?(1a)/
221
222/(?(1a))/
223
224/(?(?i))/
225
226/(?(abc))/
227
228/(?(?<ab))/
229
230/((?s)blah)\s+\1/I
231
232/((?i)blah)\s+\1/I
233
234/((?i)b)/IB
235
236/(a*b|(?i:c*(?-i)d))/I
237
238/a$/I
239    a
240    a\n
241\= Expect no match
242    a\=noteol
243    a\n\=noteol
244
245/a$/Im
246    a
247    a\n
248    a\n\=noteol
249\= Expect no match
250    a\=noteol
251
252/\Aabc/Im
253
254/^abc/Im
255
256/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/I
257  aaaaabbbbbcccccdef
258
259/(?<=foo)[ab]/I
260
261/(?<!foo)(alpha|omega)/I
262
263/(?!alphabet)[ab]/I
264
265/(?<=foo\n)^bar/Im
266    foo\nbarbar
267\= Expect no match
268    rhubarb
269    barbell
270    abc\nbarton
271
272/^(?<=foo\n)bar/Im
273    foo\nbarbar
274\= Expect no match
275    rhubarb
276    barbell
277    abc\nbarton
278
279/(?>^abc)/Im
280    abc
281    def\nabc
282\= Expect no match
283    defabc
284
285/(?<=ab(c+)d)ef/
286
287/(?<=ab(?<=c+)d)ef/
288
289/The next three are in testinput2 because they have variable length branches/
290
291/(?<=bullock|donkey)-cart/I
292    the bullock-cart
293    a donkey-cart race
294\= Expect no match
295    cart
296    horse-and-cart
297
298/(?<=ab(?i)x|y|z)/I
299
300/(?>.*)(?<=(abcd)|(xyz))/I
301    alphabetabcd
302    endingxyz
303
304/(?<=ab(?i)x(?-i)y|(?i)z|b)ZZ/I
305    abxyZZ
306    abXyZZ
307    ZZZ
308    zZZ
309    bZZ
310    BZZ
311\= Expect no match
312    ZZ
313    abXYZZ
314    zzz
315    bzz
316
317/(?<!(foo)a)bar/I
318    bar
319    foobbar
320\= Expect no match
321    fooabar
322
323# Perl does not fail these two for the final subjects.
324
325/^(xa|=?\1a){2}$/
326    xa=xaa
327\= Expect no match
328    xa=xaaa
329
330/^(xa|=?\1a)+$/
331    xa=xaa
332\= Expect no match
333    xa=xaaa
334
335# These are syntax tests from Perl 5.005
336
337/a[b-a]/
338
339/a[]b/
340
341/a[/
342
343/*a/
344
345/(*)b/
346
347/abc)/
348
349/(abc/
350
351/a**/
352
353/)(/
354
355/\1/
356
357/\2/
358
359/(a)|\2/
360
361/a[b-a]/Ii
362
363/a[]b/Ii
364
365/a[/Ii
366
367/*a/Ii
368
369/(*)b/Ii
370
371/abc)/Ii
372
373/(abc/Ii
374
375/a**/Ii
376
377/)(/Ii
378
379/:(?:/
380
381/(?<%)b/
382
383/a(?{)b/
384
385/a(?{{})b/
386
387/a(?{}})b/
388
389/a(?{"{"})b/
390
391/a(?{"{"}})b/
392
393/(?(1?)a|b)/
394
395/[a[:xyz:/
396
397/(?<=x+)y/
398
399/a{37,17}/
400
401/abc/\
402
403/abc/\i
404
405/(a)bc(d)/I
406    abcd
407    abcd\=copy=2
408    abcd\=copy=5
409
410/(.{20})/I
411    abcdefghijklmnopqrstuvwxyz
412    abcdefghijklmnopqrstuvwxyz\=copy=1
413    abcdefghijklmnopqrstuvwxyz\=get=1
414
415/(.{15})/I
416    abcdefghijklmnopqrstuvwxyz
417    abcdefghijklmnopqrstuvwxyz\=copy=1,get=1
418
419/(.{16})/I
420    abcdefghijklmnopqrstuvwxyz
421    abcdefghijklmnopqrstuvwxyz\=copy=1,get=1,getall
422
423/^(a|(bc))de(f)/I
424    adef\=get=1,get=2,get=3,get=4,getall
425    bcdef\=get=1,get=2,get=3,get=4,getall
426    adefghijk\=copy=0
427
428/^abc\00def/I
429    abc\00def\=copy=0,getall
430
431/word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
432)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+
433)?)?)?)?)?)?)?)?)?otherword/I
434
435/.*X/IB
436
437/.*X/IBs
438
439/(.*X|^B)/IB
440
441/(.*X|^B)/IBs
442
443/(?s)(.*X|^B)/IB
444
445/(?s:.*X|^B)/IB
446
447/\Biss\B/I,aftertext
448    Mississippi
449
450/iss/I,aftertext,altglobal
451    Mississippi
452
453/\Biss\B/I,aftertext,altglobal
454    Mississippi
455
456/\Biss\B/Ig,aftertext
457    Mississippi
458\= Expect no match
459    Mississippi\=anchored
460
461/(?<=[Ms])iss/Ig,aftertext
462    Mississippi
463
464/(?<=[Ms])iss/I,aftertext,altglobal
465    Mississippi
466
467/^iss/Ig,aftertext
468    ississippi
469
470/.*iss/Ig,aftertext
471    abciss\nxyzisspqr
472
473/.i./Ig,aftertext
474    Mississippi
475    Mississippi\=anchored
476    Missouri river
477    Missouri river\=anchored
478
479/^.is/Ig,aftertext
480    Mississippi
481
482/^ab\n/Ig,aftertext
483    ab\nab\ncd
484
485/^ab\n/Igm,aftertext
486    ab\nab\ncd
487
488/^/gm,newline=any
489    a\rb\nc\r\nxyz\=aftertext
490
491/abc/I
492
493/abc|bac/I
494
495/(abc|bac)/I
496
497/(abc|(c|dc))/I
498
499/(abc|(d|de)c)/I
500
501/a*/I
502
503/a+/I
504
505/(baa|a+)/I
506
507/a{0,3}/I
508
509/baa{3,}/I
510
511/"([^\\"]+|\\.)*"/I
512
513/(abc|ab[cd])/I
514
515/(a|.)/I
516
517/a|ba|\w/I
518
519/abc(?=pqr)/I
520
521/...(?<=abc)/I
522
523/abc(?!pqr)/I
524
525/ab./I
526
527/ab[xyz]/I
528
529/abc*/I
530
531/ab.c*/I
532
533/a.c*/I
534
535/.c*/I
536
537/ac*/I
538
539/(a.c*|b.c*)/I
540
541/a.c*|aba/I
542
543/.+a/I
544
545/(?=abcda)a.*/I
546
547/(?=a)a.*/I
548
549/a(b)*/I
550
551/a\d*/I
552
553/ab\d*/I
554
555/a(\d)*/I
556
557/abcde{0,0}/I
558
559/ab\d+/I
560
561/a(?(1)b)(.)/I
562
563/a(?(1)bag|big)(.)/I
564
565/a(?(1)bag|big)*(.)/I
566
567/a(?(1)bag|big)+(.)/I
568
569/a(?(1)b..|b..)(.)/I
570
571/ab\d{0}e/I
572
573/a?b?/I
574    a
575    b
576    ab
577    \
578\= Expect no match
579    \=notempty
580
581/|-/I
582    abcd
583    -abc
584    ab-c\=notempty
585\= Expect no match
586    abc\=notempty
587
588/^.?abcd/I
589
590/\(             # ( at start
591  (?:           # Non-capturing bracket
592  (?>[^()]+)    # Either a sequence of non-brackets (no backtracking)
593  |             # Or
594  (?R)          # Recurse - i.e. nested bracketed string
595  )*            # Zero or more contents
596  \)            # Closing )
597  /Ix
598    (abcd)
599    (abcd)xyz
600    xyz(abcd)
601    (ab(xy)cd)pqr
602    (ab(xycd)pqr
603    () abc ()
604    12(abcde(fsh)xyz(foo(bar))lmno)89
605\= Expect no match
606    abcd
607    abcd)
608    (abcd
609
610/\(  ( (?>[^()]+) | (?R) )* \) /Igx
611    (ab(xy)cd)pqr
612    1(abcd)(x(y)z)pqr
613
614/\(  (?: (?>[^()]+) | (?R) ) \) /Ix
615    (abcd)
616    (ab(xy)cd)
617    (a(b(c)d)e)
618    ((ab))
619\= Expect no match
620    ()
621
622/\(  (?: (?>[^()]+) | (?R) )? \) /Ix
623    ()
624    12(abcde(fsh)xyz(foo(bar))lmno)89
625
626/\(  ( (?>[^()]+) | (?R) )* \) /Ix
627    (ab(xy)cd)
628
629/\( ( ( (?>[^()]+) | (?R) )* ) \) /Ix
630    (ab(xy)cd)
631
632/\( (123)? ( ( (?>[^()]+) | (?R) )* ) \) /Ix
633    (ab(xy)cd)
634    (123ab(xy)cd)
635
636/\( ( (123)? ( (?>[^()]+) | (?R) )* ) \) /Ix
637    (ab(xy)cd)
638    (123ab(xy)cd)
639
640/\( (((((((((( ( (?>[^()]+) | (?R) )* )))))))))) \) /Ix
641    (ab(xy)cd)
642
643/\( ( ( (?>[^()<>]+) | ((?>[^()]+)) | (?R) )* ) \) /Ix
644    (abcd(xyz<p>qrs)123)
645
646/\( ( ( (?>[^()]+) | ((?R)) )* ) \) /Ix
647    (ab(cd)ef)
648    (ab(cd(ef)gh)ij)
649
650/^[[:alnum:]]/IB
651
652/^[[:^alnum:]]/IB
653
654/^[[:alpha:]]/IB
655
656/^[[:^alpha:]]/IB
657
658/[_[:alpha:]]/I
659
660/^[[:ascii:]]/IB
661
662/^[[:^ascii:]]/IB
663
664/^[[:blank:]]/IB
665
666/^[[:^blank:]]/IB
667
668/[\n\x0b\x0c\x0d[:blank:]]/I
669
670/^[[:cntrl:]]/IB
671
672/^[[:digit:]]/IB
673
674/^[[:graph:]]/IB
675
676/^[[:lower:]]/IB
677
678/^[[:print:]]/IB
679
680/^[[:punct:]]/IB
681
682/^[[:space:]]/IB
683
684/^[[:upper:]]/IB
685
686/^[[:xdigit:]]/IB
687
688/^[[:word:]]/IB
689
690/^[[:^cntrl:]]/IB
691
692/^[12[:^digit:]]/IB
693
694/^[[:^blank:]]/IB
695
696/[01[:alpha:]%]/IB
697
698/[[.ch.]]/I
699
700/[[=ch=]]/I
701
702/[[:rhubarb:]]/I
703
704/[[:upper:]]/Ii
705    A
706    a
707
708/[[:lower:]]/Ii
709    A
710    a
711
712/((?-i)[[:lower:]])[[:lower:]]/Ii
713    ab
714    aB
715\= Expect no match
716    Ab
717    AB
718
719/[\200-\110]/I
720
721/^(?(0)f|b)oo/I
722
723# This one's here because of the large output vector needed
724
725/(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\w+)\s+(\270)/I
726     1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 ABC ABC\=ovector=300
727
728# This one's here because Perl does this differently and PCRE2 can't at present
729
730/(main(O)?)+/I
731    mainmain
732    mainOmain
733
734# These are all cases where Perl does it differently (nested captures)
735
736/^(a(b)?)+$/I
737    aba
738
739/^(aa(bb)?)+$/I
740    aabbaa
741
742/^(aa|aa(bb))+$/I
743    aabbaa
744
745/^(aa(bb)??)+$/I
746    aabbaa
747
748/^(?:aa(bb)?)+$/I
749    aabbaa
750
751/^(aa(b(b))?)+$/I
752    aabbaa
753
754/^(?:aa(b(b))?)+$/I
755    aabbaa
756
757/^(?:aa(b(?:b))?)+$/I
758    aabbaa
759
760/^(?:aa(bb(?:b))?)+$/I
761    aabbbaa
762
763/^(?:aa(b(?:bb))?)+$/I
764    aabbbaa
765
766/^(?:aa(?:b(b))?)+$/I
767    aabbaa
768
769/^(?:aa(?:b(bb))?)+$/I
770    aabbbaa
771
772/^(aa(b(bb))?)+$/I
773    aabbbaa
774
775/^(aa(bb(bb))?)+$/I
776    aabbbbaa
777
778# ----------------
779
780/#/IBx
781
782/a#/IBx
783
784/[\s]/IB
785
786/[\S]/IB
787
788/a(?i)b/IB
789    ab
790    aB
791\= Expect no match
792    AB
793
794/(a(?i)b)/IB
795    ab
796    aB
797\= Expect no match
798    AB
799
800/   (?i)abc/IBx
801
802/#this is a comment
803  (?i)abc/IBx
804
805/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/IB
806
807/\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/IB
808
809/\Q\E/IB
810    \
811
812/\Q\Ex/IB
813
814/ \Q\E/IB
815
816/a\Q\E/IB
817  abc
818  bca
819  bac
820
821/a\Q\Eb/IB
822  abc
823
824/\Q\Eabc/IB
825
826/x*+\w/IB
827\= Expect no match
828    xxxxx
829
830/x?+/IB
831
832/x++/IB
833
834/x{1,3}+/B,no_auto_possess
835
836/x{1,3}+/Bi,no_auto_possess
837
838/[^x]{1,3}+/B,no_auto_possess
839
840/[^x]{1,3}+/Bi,no_auto_possess
841
842/(x)*+/IB
843
844/^(\w++|\s++)*$/I
845    now is the time for all good men to come to the aid of the party
846\= Expect no match
847    this is not a line with only words and spaces!
848
849/(\d++)(\w)/I
850    12345a
851\= Expect no match
852    12345+
853
854/a++b/I
855    aaab
856
857/(a++b)/I
858    aaab
859
860/(a++)b/I
861    aaab
862
863/([^()]++|\([^()]*\))+/I
864    ((abc(ade)ufh()()x
865
866/\(([^()]++|\([^()]+\))+\)/I
867    (abc)
868    (abc(def)xyz)
869\= Expect no match
870    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
871
872/(abc){1,3}+/IB
873
874/a+?+/I
875
876/a{2,3}?+b/I
877
878/(?U)a+?+/I
879
880/a{2,3}?+b/I,ungreedy
881
882/x(?U)a++b/IB
883    xaaaab
884
885/(?U)xa++b/IB
886    xaaaab
887
888/^((a+)(?U)([ab]+)(?-U)([bc]+)(\w*))/IB
889
890/^x(?U)a+b/IB
891
892/^x(?U)(a+)b/IB
893
894/[.x.]/I
895
896/[=x=]/I
897
898/[:x:]/I
899
900/\F/I
901
902/\l/I
903
904/\L/I
905
906/\N{name}/I
907
908/\u/I
909
910/\U/I
911
912/\N{4}/
913    abcdefg
914
915/\N{,}/
916
917/\N{25,ab}/
918
919/a{1,3}b/ungreedy
920    ab
921
922/[/I
923
924/[a-/I
925
926/[[:space:]/I
927
928/[\s]/IB
929
930/[[:space:]]/IB
931
932/[[:space:]abcde]/IB
933
934/< (?: (?(R) \d++  | [^<>]*+) | (?R)) * >/Ix
935    <>
936    <abcd>
937    <abc <123> hij>
938    <abc <def> hij>
939    <abc<>def>
940    <abc<>
941\= Expect no match
942    <abc
943
944/8J\$WE\<\.rX\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b/IB
945
946/\$\<\.X\+ix\[d1b\!H\#\?vV0vrK\:ZH1\=2M\>iV\;\?aPhFB\<\*vW\@QW\@sO9\}cfZA\-i\'w\%hKd6gt1UJP\,15_\#QY\$M\^Mss_U\/\]\&LK9\[5vQub\^w\[KDD\<EjmhUZ\?\.akp2dF\>qmj\;2\}YWFdYx\.Ap\]hjCPTP\(n28k\+3\;o\&WXqs\/gOXdr\$\:r\'do0\;b4c\(f_Gr\=\"\\4\)\[01T7ajQJvL\$W\~mL_sS\/4h\:x\*\[ZN\=KLs\&L5zX\/\/\>it\,o\:aU\(\;Z\>pW\&T7oP\'2K\^E\:x9\'c\[\%z\-\,64JQ5AeH_G\#KijUKghQw\^\\vea3a\?kka_G\$8\#\`\*kynsxzBLru\'\]k_\[7FrVx\}\^\=\$blx\>s\-N\%j\;D\*aZDnsw\:YKZ\%Q\.Kne9\#hP\?\+b3\(SOvL\,\^\;\&u5\@\?5C5Bhb\=m\-vEh_L15Jl\]U\)0RP6\{q\%L\^_z5E\'Dw6X\b/IB
947
948/(.*)\d+\1/I
949
950/(.*)\d+/I
951
952/(.*)\d+\1/Is
953
954/(.*)\d+/Is
955
956/(.*(xyz))\d+\2/I
957
958/((.*))\d+\1/I
959    abc123bc
960
961/a[b]/I
962
963/(?=a).*/I
964
965/(?=abc).xyz/Ii
966
967/(?=abc)(?i).xyz/I
968
969/(?=a)(?=b)/I
970
971/(?=.)a/I
972
973/((?=abcda)a)/I
974
975/((?=abcda)ab)/I
976
977/()a/I
978
979/(?:(?=.)|(?<!x))a/I
980
981/(?(1)ab|ac)(.)/I
982
983/(?(1)abz|acz)(.)/I
984
985/(?(1)abz)(.)/I
986
987/(?(1)abz)(1)23/I
988
989/(a)+/I
990
991/(a){2,3}/I
992
993/(a)*/I
994
995/[a]/I
996
997/[ab]/I
998
999/[ab]/I
1000
1001/[^a]/I
1002
1003/\d456/I
1004
1005/\d456/I
1006
1007/a^b/I
1008
1009/^a/Im
1010  abcde
1011  xy\nabc
1012\= Expect no match
1013  xyabc
1014
1015/c|abc/I
1016
1017/(?i)[ab]/I
1018
1019/[ab](?i)cd/I
1020
1021/abc(?C)def/I
1022    abcdef
1023    1234abcdef
1024\= Expect no match
1025    abcxyz
1026    abcxyzf
1027
1028/abc(?C)de(?C1)f/I
1029    123abcdef
1030
1031/(?C1)\dabc(?C2)def/I
1032    1234abcdef
1033\= Expect no match
1034    abcdef
1035
1036/(?C1)\dabc(?C2)def/I
1037    1234abcdef
1038\= Expect no match
1039    abcdef
1040
1041/(?C255)ab/I
1042
1043/(?C256)ab/I
1044
1045/(?Cab)xx/I
1046
1047/(?C12vr)x/I
1048
1049/abc(?C)def/I
1050    \x83\x0\x61bcdef
1051
1052/(abc)(?C)de(?C1)f/I
1053    123abcdef
1054    123abcdef\=callout_capture
1055    123abcdefC-\=callout_none
1056\= Expect no match
1057    123abcdef\=callout_fail=1
1058
1059/(?C0)(abc(?C1))*/I
1060    abcabcabc
1061    abcabc\=callout_fail=1:4
1062    abcabcabc\=callout_fail=1:4
1063
1064/(\d{3}(?C))*/I
1065    123\=callout_capture
1066    123456\=callout_capture
1067    123456789\=callout_capture
1068
1069/((xyz)(?C)p|(?C1)xyzabc)/I
1070    xyzabc\=callout_capture
1071
1072/(X)((xyz)(?C)p|(?C1)xyzabc)/I
1073    Xxyzabc\=callout_capture
1074
1075/(?=(abc))(?C)abcdef/I
1076    abcdef\=callout_capture
1077
1078/(?!(abc)(?C1)d)(?C2)abcxyz/I
1079    abcxyz\=callout_capture
1080
1081/(?<=(abc)(?C))xyz/I
1082   abcxyz\=callout_capture
1083
1084/a(b+)(c*)(?C1)/I
1085\= Expect no match
1086    abbbbbccc\=callout_data=1
1087
1088/a(b+?)(c*?)(?C1)/I
1089\= Expect no match
1090    abbbbbccc\=callout_data=1
1091
1092/(?C)abc/I
1093
1094/(?C)^abc/I
1095
1096/(?C)a|b/I
1097
1098/a|(b)(?C)/I
1099    b
1100
1101/x(ab|(bc|(de|(?R))))/I
1102    xab
1103    xbc
1104    xde
1105    xxab
1106    xxxab
1107\= Expect no match
1108    xyab
1109
1110/^([^()]|\((?1)*\))*$/I
1111    abc
1112    a(b)c
1113    a(b(c))d
1114\= Expect no match)
1115    a(b(c)d
1116
1117/^>abc>([^()]|\((?1)*\))*<xyz<$/I
1118   >abc>123<xyz<
1119   >abc>1(2)3<xyz<
1120   >abc>(1(2)3)<xyz<
1121
1122/(a(?1)b)/IB
1123
1124/(a(?1)+b)/IB
1125
1126/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/I
1127    12
1128    (((2+2)*-3)-7)
1129    -12
1130\= Expect no match
1131    ((2+2)*-3)-7)
1132
1133/^(x(y|(?1){2})z)/I
1134    xyz
1135    xxyzxyzz
1136\= Expect no match
1137    xxyzz
1138    xxyzxyzxyzz
1139
1140/((< (?: (?(R) \d++  | [^<>]*+) | (?2)) * >))/Ix
1141    <>
1142    <abcd>
1143    <abc <123> hij>
1144    <abc <def> hij>
1145    <abc<>def>
1146    <abc<>
1147\= Expect no match
1148    <abc
1149
1150/(?1)/I
1151
1152/((?2)(abc)/I
1153
1154/^(abc)def(?1)/I
1155    abcdefabc
1156
1157/^(a|b|c)=(?1)+/I
1158    a=a
1159    a=b
1160    a=bc
1161
1162/^(a|b|c)=((?1))+/I
1163    a=a
1164    a=b
1165    a=bc
1166
1167/a(?P<name1>b|c)d(?P<longername2>e)/IB
1168    abde
1169    acde
1170
1171/(?:a(?P<c>c(?P<d>d)))(?P<a>a)/IB
1172
1173/(?P<a>a)...(?P=a)bbb(?P>a)d/IB
1174
1175/^\W*(?:(?P<one>(?P<two>.)\W*(?P>one)\W*(?P=two)|)|(?P<three>(?P<four>.)\W*(?P>three)\W*(?P=four)|\W*.\W*))\W*$/Ii
1176    1221
1177    Satan, oscillate my metallic sonatas!
1178    A man, a plan, a canal: Panama!
1179    Able was I ere I saw Elba.
1180\= Expect no match
1181    The quick brown fox
1182
1183/((?(R)a|b))\1(?1)?/I
1184  bb
1185  bbaa
1186
1187/(.*)a/Is
1188
1189/(.*)a\1/Is
1190
1191/(.*)a(b)\2/Is
1192
1193/((.*)a|(.*)b)z/Is
1194
1195/((.*)a|(.*)b)z\1/Is
1196
1197/((.*)a|(.*)b)z\2/Is
1198
1199/((.*)a|(.*)b)z\3/Is
1200
1201/((.*)a|^(.*)b)z\3/Is
1202
1203/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a/Is
1204
1205/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\31/Is
1206
1207/(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\32/Is
1208
1209/(a)(bc)/IB,no_auto_capture
1210  abc
1211
1212/(?P<one>a)(bc)/IB,no_auto_capture
1213  abc
1214
1215/(a)(?P<named>bc)/IB,no_auto_capture
1216
1217/(aaa(?C1)bbb|ab)/I
1218   aaabbb
1219   aaabbb\=callout_data=0
1220   aaabbb\=callout_data=1
1221\= Expect no match
1222   aaabbb\=callout_data=-1
1223
1224/ab(?P<one>cd)ef(?P<two>gh)/I
1225    abcdefgh
1226    abcdefgh\=copy=1,get=two
1227    abcdefgh\=copy=one,copy=two
1228    abcdefgh\=copy=three
1229
1230/(?P<Tes>)(?P<Test>)/IB
1231
1232/(?P<Test>)(?P<Tes>)/IB
1233
1234/(?P<Z>zz)(?P<A>aa)/I
1235    zzaa\=copy=Z
1236    zzaa\=copy=A
1237
1238/(?P<x>eks)(?P<x>eccs)/I
1239
1240/(?P<abc>abc(?P<def>def)(?P<abc>xyz))/I
1241
1242"\[((?P<elem>\d+)(,(?P>elem))*)\]"I
1243    [10,20,30,5,5,4,4,2,43,23,4234]
1244\= Expect no match
1245    []
1246
1247"\[((?P<elem>\d+)(,(?P>elem))*)?\]"I
1248    [10,20,30,5,5,4,4,2,43,23,4234]
1249    []
1250
1251/(a(b(?2)c))?/IB
1252
1253/(a(b(?2)c))*/IB
1254
1255/(a(b(?2)c)){0,2}/IB
1256
1257/[ab]{1}+/B
1258
1259/()(?1){1}/B
1260
1261/()(?1)/B
1262
1263/((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/Ii
1264     Baby Bjorn Active Carrier - With free SHIPPING!!
1265
1266/((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)/Ii
1267     Baby Bjorn Active Carrier - With free SHIPPING!!
1268
1269/a*.*b/IB
1270
1271/(a|b)*.?c/IB
1272
1273/abc(?C255)de(?C)f/IB
1274
1275/abcde/IB,auto_callout
1276  abcde
1277\= Expect no match
1278  abcdfe
1279
1280/a*b/IB,auto_callout
1281  ab
1282  aaaab
1283  aaaacb
1284
1285/a*b/IB,auto_callout
1286  ab
1287  aaaab
1288  aaaacb
1289
1290/a+b/IB,auto_callout
1291  ab
1292  aaaab
1293\= Expect no match
1294  aaaacb
1295
1296/(abc|def)x/IB,auto_callout
1297  abcx
1298  defx
1299\= Expect no match
1300  abcdefzx
1301
1302/(abc|def)x/IB,auto_callout
1303  abcx
1304  defx
1305\= Expect no match
1306  abcdefzx
1307
1308/(ab|cd){3,4}/I,auto_callout
1309  ababab
1310  abcdabcd
1311  abcdcdcdcdcd
1312
1313/([ab]{,}c|xy)/IB,auto_callout
1314\= Expect no match
1315    Note: that {,} does NOT introduce a quantifier
1316
1317/([ab]{,}c|xy)/IB,auto_callout
1318\= Expect no match
1319    Note: that {,} does NOT introduce a quantifier
1320
1321/([ab]{1,4}c|xy){4,5}?123/IB,auto_callout
1322    aacaacaacaacaac123
1323
1324/\b.*/I
1325  ab cd\=offset=1
1326
1327/\b.*/Is
1328  ab cd\=startoffset=1
1329
1330/(?!.bcd).*/I
1331  Xbcd12345
1332
1333/abcde/I
1334    ab\=ps
1335    abc\=ps
1336    abcd\=ps
1337    abcde\=ps
1338    the quick brown abc\=ps
1339\= Expect no match\=ps
1340    the quick brown abxyz fox\=ps
1341
1342"^(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/(20)?\d\d$"I
1343    13/05/04\=ps
1344    13/5/2004\=ps
1345    02/05/09\=ps
1346    1\=ps
1347    1/2\=ps
1348    1/2/0\=ps
1349    1/2/04\=ps
1350    0\=ps
1351    02/\=ps
1352    02/0\=ps
1353    02/1\=ps
1354\= Expect no match\=ps
1355    \=ps
1356    123\=ps
1357    33/4/04\=ps
1358    3/13/04\=ps
1359    0/1/2003\=ps
1360    0/\=ps
1361    02/0/\=ps
1362    02/13\=ps
1363
1364/0{0,2}ABC/I
1365
1366/\d{3,}ABC/I
1367
1368/\d*ABC/I
1369
1370/[abc]+DE/I
1371
1372/[abc]?123/I
1373    123\=ps
1374    a\=ps
1375    b\=ps
1376    c\=ps
1377    c12\=ps
1378    c123\=ps
1379
1380/^(?:\d){3,5}X/I
1381    1\=ps
1382    123\=ps
1383    123X
1384    1234\=ps
1385    1234X
1386    12345\=ps
1387    12345X
1388\= Expect no match
1389    1X
1390    123456\=ps
1391
1392"<(\w+)/?>(.)*</(\1)>"Igms
1393    <!DOCTYPE seite SYSTEM "http://www.lco.lineas.de/xmlCms.dtd">\n<seite>\n<dokumenteninformation>\n<seitentitel>Partner der LCO</seitentitel>\n<sprache>de</sprache>\n<seitenbeschreibung>Partner der LINEAS Consulting\nGmbH</seitenbeschreibung>\n<schluesselworte>LINEAS Consulting GmbH Hamburg\nPartnerfirmen</schluesselworte>\n<revisit>30 days</revisit>\n<robots>index,follow</robots>\n<menueinformation>\n<aktiv>ja</aktiv>\n<menueposition>3</menueposition>\n<menuetext>Partner</menuetext>\n</menueinformation>\n<lastedited>\n<autor>LCO</autor>\n<firma>LINEAS Consulting</firma>\n<datum>15.10.2003</datum>\n</lastedited>\n</dokumenteninformation>\n<inhalt>\n\n<absatzueberschrift>Die Partnerfirmen der LINEAS Consulting\nGmbH</absatzueberschrift>\n\n<absatz><link ziel="http://www.ca.com/" zielfenster="_blank">\n<bild name="logo_ca.gif" rahmen="no"/></link> <link\nziel="http://www.ey.com/" zielfenster="_blank"><bild\nname="logo_euy.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><link ziel="http://www.cisco.de/" zielfenster="_blank">\n<bild name="logo_cisco.gif" rahmen="ja"/></link></absatz>\n\n<absatz><link ziel="http://www.atelion.de/"\nzielfenster="_blank"><bild\nname="logo_atelion.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><link ziel="http://www.line-information.de/"\nzielfenster="_blank">\n<bild name="logo_line_information.gif" rahmen="no"/></link>\n</absatz>\n\n<absatz><bild name="logo_aw.gif" rahmen="no"/></absatz>\n\n<absatz><link ziel="http://www.incognis.de/"\nzielfenster="_blank"><bild\nname="logo_incognis.gif" rahmen="no"/></link></absatz>\n\n<absatz><link ziel="http://www.addcraft.com/"\nzielfenster="_blank"><bild\nname="logo_addcraft.gif" rahmen="no"/></link></absatz>\n\n<absatz><link ziel="http://www.comendo.com/"\nzielfenster="_blank"><bild\nname="logo_comendo.gif" rahmen="no"/></link></absatz>\n\n</inhalt>\n</seite>\=jitstack=1024
1394
1395/line\nbreak/I
1396    this is a line\nbreak
1397    line one\nthis is a line\nbreak in the second line
1398
1399/line\nbreak/I,firstline
1400    this is a line\nbreak
1401\= Expect no match
1402    line one\nthis is a line\nbreak in the second line
1403
1404/line\nbreak/Im,firstline
1405    this is a line\nbreak
1406\= Expect no match
1407    line one\nthis is a line\nbreak in the second line
1408
1409/(?i)(?-i)AbCd/I
1410    AbCd
1411\= Expect no match
1412    abcd
1413
1414/a{11111111111111111111}/I
1415
1416/(){64294967295}/I
1417
1418/(){2,4294967295}/I
1419
1420"(?i:a)(?i:b)(?i:c)(?i:d)(?i:e)(?i:f)(?i:g)(?i:h)(?i:i)(?i:j)(k)(?i:l)A\1B"I
1421    abcdefghijklAkB
1422
1423"(?P<n0>a)(?P<n1>b)(?P<n2>c)(?P<n3>d)(?P<n4>e)(?P<n5>f)(?P<n6>g)(?P<n7>h)(?P<n8>i)(?P<n9>j)(?P<n10>k)(?P<n11>l)A\11B"I
1424    abcdefghijklAkB
1425
1426"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)A\11B"I
1427    abcdefghijklAkB
1428
1429"(?P<name0>a)(?P<name1>a)(?P<name2>a)(?P<name3>a)(?P<name4>a)(?P<name5>a)(?P<name6>a)(?P<name7>a)(?P<name8>a)(?P<name9>a)(?P<name10>a)(?P<name11>a)(?P<name12>a)(?P<name13>a)(?P<name14>a)(?P<name15>a)(?P<name16>a)(?P<name17>a)(?P<name18>a)(?P<name19>a)(?P<name20>a)(?P<name21>a)(?P<name22>a)(?P<name23>a)(?P<name24>a)(?P<name25>a)(?P<name26>a)(?P<name27>a)(?P<name28>a)(?P<name29>a)(?P<name30>a)(?P<name31>a)(?P<name32>a)(?P<name33>a)(?P<name34>a)(?P<name35>a)(?P<name36>a)(?P<name37>a)(?P<name38>a)(?P<name39>a)(?P<name40>a)(?P<name41>a)(?P<name42>a)(?P<name43>a)(?P<name44>a)(?P<name45>a)(?P<name46>a)(?P<name47>a)(?P<name48>a)(?P<name49>a)(?P<name50>a)(?P<name51>a)(?P<name52>a)(?P<name53>a)(?P<name54>a)(?P<name55>a)(?P<name56>a)(?P<name57>a)(?P<name58>a)(?P<name59>a)(?P<name60>a)(?P<name61>a)(?P<name62>a)(?P<name63>a)(?P<name64>a)(?P<name65>a)(?P<name66>a)(?P<name67>a)(?P<name68>a)(?P<name69>a)(?P<name70>a)(?P<name71>a)(?P<name72>a)(?P<name73>a)(?P<name74>a)(?P<name75>a)(?P<name76>a)(?P<name77>a)(?P<name78>a)(?P<name79>a)(?P<name80>a)(?P<name81>a)(?P<name82>a)(?P<name83>a)(?P<name84>a)(?P<name85>a)(?P<name86>a)(?P<name87>a)(?P<name88>a)(?P<name89>a)(?P<name90>a)(?P<name91>a)(?P<name92>a)(?P<name93>a)(?P<name94>a)(?P<name95>a)(?P<name96>a)(?P<name97>a)(?P<name98>a)(?P<name99>a)(?P<name100>a)"I
1430    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1431
1432"(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)(a)"I
1433    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
1434
1435/[^()]*(?:\((?R)\)[^()]*)*/I
1436    (this(and)that
1437    (this(and)that)
1438    (this(and)that)stuff
1439
1440/[^()]*(?:\((?>(?R))\)[^()]*)*/I
1441    (this(and)that
1442    (this(and)that)
1443
1444/[^()]*(?:\((?R)\))*[^()]*/I
1445    (this(and)that
1446    (this(and)that)
1447
1448/(?:\((?R)\))*[^()]*/I
1449    (this(and)that
1450    (this(and)that)
1451    ((this))
1452
1453/(?:\((?R)\))|[^()]*/I
1454    (this(and)that
1455    (this(and)that)
1456    (this)
1457    ((this))
1458
1459/\x{0000ff}/I
1460
1461/^((?P<A>a1)|(?P<A>a2)b)/I
1462
1463/^((?P<A>a1)|(?P<A>a2)b)/I,dupnames
1464    a1b\=copy=A
1465    a2b\=copy=A
1466    a1b\=copy=Z,copy=A
1467
1468/(?|(?<a>)(?<b>)(?<a>)|(?<a>)(?<b>)(?<a>))/I,dupnames
1469
1470/^(?P<A>a)(?P<A>b)/I,dupnames
1471    ab\=copy=A
1472
1473/^(?P<A>a)(?P<A>b)|cd/I,dupnames
1474    ab\=copy=A
1475    cd\=copy=A
1476
1477/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/I,dupnames
1478    cdefgh\=copy=A
1479
1480/^((?P<A>a1)|(?P<A>a2)b)/I,dupnames
1481    a1b\=get=A
1482    a2b\=get=A
1483    a1b\=get=Z,get=A
1484
1485/^(?P<A>a)(?P<A>b)/I,dupnames
1486    ab\=get=A
1487
1488/^(?P<A>a)(?P<A>b)|cd/I,dupnames
1489    ab\=get=A
1490    cd\=get=A
1491
1492/^(?P<A>a)(?P<A>b)|cd(?P<A>ef)(?P<A>gh)/I,dupnames
1493    cdefgh\=get=A
1494
1495/(?J)^((?P<A>a1)|(?P<A>a2)b)/I
1496    a1b\=copy=A
1497    a2b\=copy=A
1498
1499/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<A>d)/I
1500
1501# In this next test, J is not set at the outer level; consequently it isn't set
1502# in the pattern's options; consequently pcre2_substring_get_byname() produces
1503# a random value.
1504
1505/^(?P<A>a) (?J:(?P<B>b)(?P<B>c)) (?P<C>d)/I
1506    a bc d\=copy=A,copy=B,copy=C
1507
1508/^(?P<A>a)?(?(A)a|b)/I
1509    aabc
1510    bc
1511\= Expect no match
1512    abc
1513
1514/(?:(?(ZZ)a|b)(?P<ZZ>X))+/I
1515    bXaX
1516
1517/(?:(?(2y)a|b)(X))+/I
1518
1519/(?:(?(ZA)a|b)(?P<ZZ>X))+/I
1520
1521/(?:(?(ZZ)a|b)(?(ZZ)a|b)(?P<ZZ>X))+/I
1522    bbXaaX
1523
1524/(?:(?(ZZ)a|\(b\))\\(?P<ZZ>X))+/I
1525    (b)\\Xa\\X
1526
1527/(?P<ABC/I
1528
1529/(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
1530    bXXaYYaY
1531    bXYaXXaX
1532
1533/()()()()()()()()()(?:(?(A)(?P=A)a|b)(?P<A>X|Y))+/I
1534    bXXaYYaY
1535
1536/\s*,\s*/I
1537    \x0b,\x0b
1538    \x0c,\x0d
1539
1540/^abc/Im,newline=lf
1541    xyz\nabc
1542    xyz\r\nabc
1543\= Expect no match
1544    xyz\rabc
1545    xyzabc\r
1546    xyzabc\rpqr
1547    xyzabc\r\n
1548    xyzabc\r\npqr
1549
1550/^abc/Im,newline=crlf
1551    xyz\r\nabclf>
1552\= Expect no match
1553    xyz\nabclf
1554    xyz\rabclf
1555
1556/^abc/Im,newline=cr
1557    xyz\rabc
1558\= Expect no match
1559    xyz\nabc
1560    xyz\r\nabc
1561
1562/^abc/Im,newline=bad
1563
1564/.*/I,newline=lf
1565    abc\ndef
1566    abc\rdef
1567    abc\r\ndef
1568
1569/.*/I,newline=cr
1570    abc\ndef
1571    abc\rdef
1572    abc\r\ndef
1573
1574/.*/I,newline=crlf
1575    abc\ndef
1576    abc\rdef
1577    abc\r\ndef
1578
1579/\w+(.)(.)?def/Is
1580    abc\ndef
1581    abc\rdef
1582    abc\r\ndef
1583
1584/(?P<B>25[0-5]|2[0-4]\d|[01]?\d?\d)(?:\.(?P>B)){3}/I
1585
1586/()()()()()()()()()()()()()()()()()()()()
1587 ()()()()()()()()()()()()()()()()()()()()
1588 ()()()()()()()()()()()()()()()()()()()()
1589 ()()()()()()()()()()()()()()()()()()()()
1590 ()()()()()()()()()()()()()()()()()()()()
1591 (.(.))/Ix
1592    XY\=ovector=133
1593
1594/(a*b|(?i:c*(?-i)d))/I
1595
1596/()[ab]xyz/I
1597
1598/(|)[ab]xyz/I
1599
1600/(|c)[ab]xyz/I
1601
1602/(|c?)[ab]xyz/I
1603
1604/(d?|c?)[ab]xyz/I
1605
1606/(d?|c)[ab]xyz/I
1607
1608/^a*b\d/IB
1609
1610/^a*+b\d/IB
1611
1612/^a*?b\d/IB
1613
1614/^a+A\d/IB
1615    aaaA5
1616\= Expect no match
1617    aaaa5
1618
1619/^a*A\d/IBi
1620    aaaA5
1621    aaaa5
1622    a5
1623
1624/(a*|b*)[cd]/I
1625
1626/(a+|b*)[cd]/I
1627
1628/(a*|b+)[cd]/I
1629
1630/(a+|b+)[cd]/I
1631
1632/((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
1633 ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
1634 (((
1635 a
1636 ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
1637 ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
1638 )))
1639/Ix
1640  large nest
1641
1642/a*\d/B
1643
1644/a*\D/B
1645
1646/0*\d/B
1647
1648/0*\D/B
1649
1650/a*\s/B
1651
1652/a*\S/B
1653
1654/ *\s/B
1655
1656/ *\S/B
1657
1658/a*\w/B
1659
1660/a*\W/B
1661
1662/=*\w/B
1663
1664/=*\W/B
1665
1666/\d*a/B
1667
1668/\d*2/B
1669
1670/\d*\d/B
1671
1672/\d*\D/B
1673
1674/\d*\s/B
1675
1676/\d*\S/B
1677
1678/\d*\w/B
1679
1680/\d*\W/B
1681
1682/\D*a/B
1683
1684/\D*2/B
1685
1686/\D*\d/B
1687
1688/\D*\D/B
1689
1690/\D*\s/B
1691
1692/\D*\S/B
1693
1694/\D*\w/B
1695
1696/\D*\W/B
1697
1698/\s*a/B
1699
1700/\s*2/B
1701
1702/\s*\d/B
1703
1704/\s*\D/B
1705
1706/\s*\s/B
1707
1708/\s*\S/B
1709
1710/\s*\w/B
1711
1712/\s*\W/B
1713
1714/\S*a/B
1715
1716/\S*2/B
1717
1718/\S*\d/B
1719
1720/\S*\D/B
1721
1722/\S*\s/B
1723
1724/\S*\S/B
1725
1726/\S*\w/B
1727
1728/\S*\W/B
1729
1730/\w*a/B
1731
1732/\w*2/B
1733
1734/\w*\d/B
1735
1736/\w*\D/B
1737
1738/\w*\s/B
1739
1740/\w*\S/B
1741
1742/\w*\w/B
1743
1744/\w*\W/B
1745
1746/\W*a/B
1747
1748/\W*2/B
1749
1750/\W*\d/B
1751
1752/\W*\D/B
1753
1754/\W*\s/B
1755
1756/\W*\S/B
1757
1758/\W*\w/B
1759
1760/\W*\W/B
1761
1762/[^a]+a/B
1763
1764/[^a]+a/Bi
1765
1766/[^a]+A/Bi
1767
1768/[^a]+b/B
1769
1770/[^a]+\d/B
1771
1772/a*[^a]/B
1773
1774/(?P<abc>x)(?P<xyz>y)/I
1775    xy\=copy=abc,copy=xyz
1776
1777/(?<abc>x)(?'xyz'y)/I
1778    xy\=copy=abc,copy=xyz
1779
1780/(?<abc'x)(?'xyz'y)/I
1781
1782/(?<abc>x)(?'xyz>y)/I
1783
1784/(?P'abc'x)(?P<xyz>y)/I
1785
1786/^(?:(?(ZZ)a|b)(?<ZZ>X))+/
1787    bXaX
1788    bXbX
1789\= Expect no match
1790    aXaX
1791    aXbX
1792
1793/^(?P>abc)(?<abcd>xxx)/
1794
1795/^(?P>abc)(?<abc>x|y)/
1796    xx
1797    xy
1798    yy
1799    yx
1800
1801/^(?P>abc)(?P<abc>x|y)/
1802    xx
1803    xy
1804    yy
1805    yx
1806
1807/^((?(abc)a|b)(?<abc>x|y))+/
1808    bxay
1809    bxby
1810\= Expect no match
1811    axby
1812
1813/^(((?P=abc)|X)(?<abc>x|y))+/
1814    XxXxxx
1815    XxXyyx
1816    XxXyxx
1817\= Expect no match
1818    x
1819
1820/^(?1)(abc)/
1821    abcabc
1822
1823/^(?:(?:\1|X)(a|b))+/
1824    Xaaa
1825    Xaba
1826
1827/^[\E\Qa\E-\Qz\E]+/B
1828
1829/^[a\Q]bc\E]/B
1830
1831/^[a-\Q\E]/B
1832
1833/^(?P>abc)[()](?<abc>)/B
1834
1835/^((?(abc)y)[()](?P<abc>x))+/B
1836    (xy)x
1837
1838/^(?P>abc)\Q()\E(?<abc>)/B
1839
1840/^(?P>abc)[a\Q(]\E(](?<abc>)/B
1841
1842/^(?P>abc) # this is (a comment)
1843  (?<abc>)/Bx
1844
1845/^\W*(?:(?<one>(?<two>.)\W*(?&one)\W*\k<two>|)|(?<three>(?<four>.)\W*(?&three)\W*\k'four'|\W*.\W*))\W*$/Ii
1846    1221
1847    Satan, oscillate my metallic sonatas!
1848    A man, a plan, a canal: Panama!
1849    Able was I ere I saw Elba.
1850\= Expect no match
1851    The quick brown fox
1852
1853/(?=(\w+))\1:/I
1854    abcd:
1855
1856/(?=(?'abc'\w+))\k<abc>:/I
1857    abcd:
1858
1859/(?'abc'a|b)(?<abc>d|e)\k<abc>{2}/dupnames
1860    adaa
1861\= Expect no match
1862    addd
1863    adbb
1864
1865/(?'abc'a|b)(?<abc>d|e)(?&abc){2}/dupnames
1866    bdaa
1867    bdab
1868\= Expect no match
1869    bddd
1870
1871/(?(<bc))/
1872
1873/(?(''))/
1874
1875/(?('R')stuff)/
1876
1877/((abc (?(R) (?(R1)1) (?(R2)2) X  |  (?1)  (?2)   (?R) ))) /x
1878    abcabc1Xabc2XabcXabcabc
1879
1880/(?<A> (?'B' abc (?(R) (?(R&A)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
1881    abcabc1Xabc2XabcXabcabc
1882
1883/(?<A> (?'B' abc (?(R) (?(R&C)1) (?(R&B)2) X  |  (?1)  (?2)   (?R) ))) /x
1884
1885/^(?(DEFINE) abc | xyz ) /x
1886
1887/(?(DEFINE) abc) xyz/Ix
1888
1889/(a|)*\d/
1890  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4\=ovector=0
1891\= Expect no match
1892  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\=ovector=0
1893
1894/^a.b/newline=lf
1895    a\rb
1896\= Expect no match
1897    a\nb
1898
1899/^a.b/newline=cr
1900    a\nb
1901\= Expect no match
1902    a\rb
1903
1904/^a.b/newline=anycrlf
1905    a\x85b
1906\= Expect no match
1907    a\rb
1908
1909/^a.b/newline=any
1910\= Expect no match
1911    a\nb
1912    a\rb
1913    a\x85b
1914
1915/^abc./gmx,newline=any
1916    abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x85abc7 JUNK
1917
1918/abc.$/gmx,newline=any
1919    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc7 abc9
1920
1921/^a\Rb/bsr=unicode
1922    a\nb
1923    a\rb
1924    a\r\nb
1925    a\x0bb
1926    a\x0cb
1927    a\x85b
1928\= Expect no match
1929    a\n\rb
1930
1931/^a\R*b/bsr=unicode
1932    ab
1933    a\nb
1934    a\rb
1935    a\r\nb
1936    a\x0bb
1937    a\x0cb
1938    a\x85b
1939    a\n\rb
1940    a\n\r\x85\x0cb
1941
1942/^a\R+b/bsr=unicode
1943    a\nb
1944    a\rb
1945    a\r\nb
1946    a\x0bb
1947    a\x0cb
1948    a\x85b
1949    a\n\rb
1950    a\n\r\x85\x0cb
1951\= Expect no match
1952    ab
1953
1954/^a\R{1,3}b/bsr=unicode
1955    a\nb
1956    a\n\rb
1957    a\n\r\x85b
1958    a\r\n\r\nb
1959    a\r\n\r\n\r\nb
1960    a\n\r\n\rb
1961    a\n\n\r\nb
1962\= Expect no match
1963    a\n\n\n\rb
1964    a\r
1965
1966/(?&abc)X(?<abc>P)/I
1967    abcPXP123
1968
1969/(?1)X(?<abc>P)/I
1970    abcPXP123
1971
1972/(?:a(?&abc)b)*(?<abc>x)/
1973    123axbaxbaxbx456
1974    123axbaxbaxb456
1975
1976/(?:a(?&abc)b){1,5}(?<abc>x)/
1977    123axbaxbaxbx456
1978
1979/(?:a(?&abc)b){2,5}(?<abc>x)/
1980    123axbaxbaxbx456
1981
1982/(?:a(?&abc)b){2,}(?<abc>x)/
1983    123axbaxbaxbx456
1984
1985/(abc)(?i:(?1))/
1986    defabcabcxyz
1987\= Expect no match
1988    DEFabcABCXYZ
1989
1990/(abc)(?:(?i)(?1))/
1991    defabcabcxyz
1992\= Expect no match
1993    DEFabcABCXYZ
1994
1995/^(a)\g-2/
1996
1997/^(a)\g/
1998
1999/^(a)\g{0}/
2000
2001/^(a)\g{3/
2002
2003/^(a)\g{aa}/
2004
2005/^a.b/newline=lf
2006    a\rb
2007\= Expect no match
2008    a\nb
2009
2010/.+foo/
2011    afoo
2012\= Expect no match
2013    \r\nfoo
2014    \nfoo
2015
2016/.+foo/newline=crlf
2017    afoo
2018    \nfoo
2019\= Expect no match
2020    \r\nfoo
2021
2022/.+foo/newline=any
2023    afoo
2024\= Expect no match
2025    \nfoo
2026    \r\nfoo
2027
2028/.+foo/s
2029    afoo
2030    \r\nfoo
2031    \nfoo
2032
2033/^$/gm,newline=any
2034    abc\r\rxyz
2035    abc\n\rxyz
2036\= Expect no match
2037    abc\r\nxyz
2038
2039/(?m)^$/g,newline=any,aftertext
2040    abc\r\n\r\n
2041
2042/(?m)^$|^\r\n/g,newline=any,aftertext
2043    abc\r\n\r\n
2044
2045/(?m)$/g,newline=any,aftertext
2046    abc\r\n\r\n
2047
2048/abc.$/gmx,newline=anycrlf
2049    abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc9
2050
2051/^X/m
2052    XABC
2053\= Expect no match
2054    XABC\=notbol
2055
2056/(ab|c)(?-1)/B
2057    abc
2058
2059/xy(?+1)(abc)/B
2060    xyabcabc
2061\= Expect no match
2062    xyabc
2063
2064/x(?-0)y/
2065
2066/x(?-1)y/
2067
2068/x(?+0)y/
2069
2070/x(?+1)y/
2071
2072/^(abc)?(?(-1)X|Y)/B
2073    abcX
2074    Y
2075\= Expect no match
2076    abcY
2077
2078/^((?(+1)X|Y)(abc))+/B
2079    YabcXabc
2080    YabcXabcXabc
2081\= Expect no match
2082    XabcXabc
2083
2084/(?(-1)a)/B
2085
2086/((?(-1)a))/B
2087
2088/((?(-2)a))/B
2089
2090/^(?(+1)X|Y)(.)/B
2091    Y!
2092
2093/(?<A>tom|bon)-\k{A}/
2094    tom-tom
2095    bon-bon
2096\= Expect no match
2097    tom-bon
2098
2099/\g{A/
2100
2101/(?|(abc)|(xyz))/B
2102   >abc<
2103   >xyz<
2104
2105/(x)(?|(abc)|(xyz))(x)/B
2106    xabcx
2107    xxyzx
2108
2109/(x)(?|(abc)(pqr)|(xyz))(x)/B
2110    xabcpqrx
2111    xxyzx
2112
2113/\H++X/B
2114\= Expect no match
2115    XXXX
2116
2117/\H+\hY/B
2118    XXXX Y
2119
2120/\H+ Y/B
2121
2122/\h+A/B
2123
2124/\v*B/B
2125
2126/\V+\x0a/B
2127
2128/A+\h/B
2129
2130/ *\H/B
2131
2132/A*\v/B
2133
2134/\x0b*\V/B
2135
2136/\d+\h/B
2137
2138/\d*\v/B
2139
2140/S+\h\S+\v/B
2141
2142/\w{3,}\h\w+\v/B
2143
2144/\h+\d\h+\w\h+\S\h+\H/B
2145
2146/\v+\d\v+\w\v+\S\v+\V/B
2147
2148/\H+\h\H+\d/B
2149
2150/\V+\v\V+\w/B
2151
2152/\( (?: [^()]* | (?R) )* \)/x
2153(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(0(00)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)0)\=jitstack=1024
2154
2155/[\E]AAA/
2156
2157/[\Q\E]AAA/
2158
2159/[^\E]AAA/
2160
2161/[^\Q\E]AAA/
2162
2163/[\E^]AAA/
2164
2165/[\Q\E^]AAA/
2166
2167/A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/B
2168
2169/^a+(*FAIL)/auto_callout
2170\= Expect no match
2171    aaaaaa
2172
2173/a+b?c+(*FAIL)/auto_callout
2174\= Expect no match
2175    aaabccc
2176
2177/a+b?(*PRUNE)c+(*FAIL)/auto_callout
2178\= Expect no match
2179    aaabccc
2180
2181/a+b?(*COMMIT)c+(*FAIL)/auto_callout
2182\= Expect no match
2183    aaabccc
2184
2185/a+b?(*SKIP)c+(*FAIL)/auto_callout
2186\= Expect no match
2187    aaabcccaaabccc
2188
2189/a+b?(*THEN)c+(*FAIL)/auto_callout
2190\= Expect no match
2191    aaabccc
2192
2193/a(*MARK)b/
2194
2195/\g6666666666/
2196
2197/[\g6666666666]/B
2198
2199/(?1)\c[/
2200
2201/.+A/newline=crlf
2202\= Expect no match
2203    \r\nA
2204
2205/\nA/newline=crlf
2206    \r\nA
2207
2208/[\r\n]A/newline=crlf
2209    \r\nA
2210
2211/(\r|\n)A/newline=crlf
2212    \r\nA
2213
2214/a(*CR)b/
2215
2216/(*CR)a.b/
2217    a\nb
2218\= Expect no match
2219    a\rb
2220
2221/(*CR)a.b/newline=lf
2222    a\nb
2223\= Expect no match
2224    a\rb
2225
2226/(*LF)a.b/newline=CRLF
2227    a\rb
2228\= Expect no match
2229    a\nb
2230
2231/(*CRLF)a.b/
2232    a\rb
2233    a\nb
2234\= Expect no match
2235    a\r\nb
2236
2237/(*ANYCRLF)a.b/newline=CR
2238\= Expect no match
2239    a\rb
2240    a\nb
2241    a\r\nb
2242
2243/(*ANY)a.b/newline=cr
2244\= Expect no match
2245    a\rb
2246    a\nb
2247    a\r\nb
2248    a\x85b
2249
2250/(*ANY).*/g
2251    abc\r\ndef
2252
2253/(*ANYCRLF).*/g
2254    abc\r\ndef
2255
2256/(*CRLF).*/g
2257    abc\r\ndef
2258
2259/(*NUL)^.*/
2260    a\nb\x00ccc
2261
2262/(*NUL)^.*/s
2263    a\nb\x00ccc
2264
2265/^x/m,newline=NUL
2266    ab\x00xy
2267
2268/'#comment' 0d 0a 00 '^x\' 0a 'y'/x,newline=nul,hex
2269    x\nyz
2270
2271/(*NUL)^X\NY/
2272    X\nY
2273    X\rY
2274\= Expect no match
2275    X\x00Y
2276
2277/a\Rb/I,bsr=anycrlf
2278    a\rb
2279    a\nb
2280    a\r\nb
2281\= Expect no match
2282    a\x85b
2283    a\x0bb
2284
2285/a\Rb/I,bsr=unicode
2286    a\rb
2287    a\nb
2288    a\r\nb
2289    a\x85b
2290    a\x0bb
2291
2292/a\R?b/I,bsr=anycrlf
2293    a\rb
2294    a\nb
2295    a\r\nb
2296\= Expect no match
2297    a\x85b
2298    a\x0bb
2299
2300/a\R?b/I,bsr=unicode
2301    a\rb
2302    a\nb
2303    a\r\nb
2304    a\x85b
2305    a\x0bb
2306
2307/a\R{2,4}b/I,bsr=anycrlf
2308    a\r\n\nb
2309    a\n\r\rb
2310    a\r\n\r\n\r\n\r\nb
2311\= Expect no match
2312    a\x85\x85b
2313    a\x0b\x0bb
2314
2315/a\R{2,4}b/I,bsr=unicode
2316    a\r\rb
2317    a\n\n\nb
2318    a\r\n\n\r\rb
2319    a\x85\x85b
2320    a\x0b\x0bb
2321\= Expect no match
2322    a\r\r\r\r\rb
2323
2324/(*BSR_ANYCRLF)a\Rb/I
2325    a\nb
2326    a\rb
2327
2328/(*BSR_UNICODE)a\Rb/I
2329    a\x85b
2330
2331/(*BSR_ANYCRLF)(*CRLF)a\Rb/I
2332    a\nb
2333    a\rb
2334
2335/(*CRLF)(*BSR_UNICODE)a\Rb/I
2336    a\x85b
2337
2338/(*CRLF)(*BSR_ANYCRLF)(*CR)ab/I
2339
2340/(?<a>)(?&)/
2341
2342/(?<abc>)(?&a)/
2343
2344/(?<a>)(?&aaaaaaaaaaaaaaaaaaaaaaa)/
2345
2346/(?+-a)/
2347
2348/(?-+a)/
2349
2350/(?(-1))/
2351
2352/(?(+10))/
2353
2354/(?(10))/
2355
2356/(?(+2))()()/
2357
2358/(?(2))()()/
2359
2360/\k''/
2361
2362/\k<>/
2363
2364/\k{}/
2365
2366/\k/
2367
2368/\kabc/
2369
2370/(?P=)/
2371
2372/(?P>)/
2373
2374/[[:foo:]]/
2375
2376/[[:1234:]]/
2377
2378/[[:f\oo:]]/
2379
2380/[[: :]]/
2381
2382/[[:...:]]/
2383
2384/[[:l\ower:]]/
2385
2386/[[:abc\:]]/
2387
2388/[abc[:x\]pqr:]]/
2389
2390/[[:a\dz:]]/
2391
2392/(^(a|b\g<-1'c))/
2393
2394/^(?+1)(?<a>x|y){0}z/
2395    xzxx
2396    yzyy
2397\= Expect no match
2398    xxz
2399
2400/(\3)(\1)(a)/
2401\= Expect no match
2402    cat
2403
2404/(\3)(\1)(a)/allow_empty_class,match_unset_backref,dupnames
2405    cat
2406
2407/TA]/
2408    The ACTA] comes
2409
2410/TA]/allow_empty_class,match_unset_backref,dupnames
2411    The ACTA] comes
2412
2413/(?2)[]a()b](abc)/
2414    abcbabc
2415
2416/(?2)[^]a()b](abc)/
2417    abcbabc
2418
2419/(?1)[]a()b](abc)/
2420    abcbabc
2421\= Expect no match
2422    abcXabc
2423
2424/(?1)[^]a()b](abc)/
2425    abcXabc
2426\= Expect no match
2427    abcbabc
2428
2429/(?2)[]a()b](abc)(xyz)/
2430    xyzbabcxyz
2431
2432/(?&N)[]a(?<N>)](?<M>abc)/
2433   abc<abc
2434
2435/(?&N)[]a(?<N>)](abc)/
2436   abc<abc
2437
2438/a[]b/
2439
2440/a[^]b/
2441
2442/a[]b/allow_empty_class,match_unset_backref,dupnames
2443\= Expect no match
2444    ab
2445
2446/a[]+b/allow_empty_class,match_unset_backref,dupnames
2447\= Expect no match
2448    ab
2449
2450/a[]*+b/allow_empty_class,match_unset_backref,dupnames
2451\= Expect no match
2452    ab
2453
2454/a[^]b/allow_empty_class,match_unset_backref,dupnames
2455    aXb
2456    a\nb
2457\= Expect no match
2458    ab
2459
2460/a[^]+b/allow_empty_class,match_unset_backref,dupnames
2461    aXb
2462    a\nX\nXb
2463\= Expect no match
2464    ab
2465
2466/a(?!)b/B
2467
2468/(?!)?a/B
2469    ab
2470
2471/a(*FAIL)+b/
2472
2473/(abc|pqr|123){0}[xyz]/I
2474
2475/(?(?=.*b)b|^)/I,auto_callout
2476   adc
2477   abc
2478
2479/(?(?=b).*b|^d)/I
2480
2481/(?(?=.*b).*b|^d)/I
2482
2483/xyz/auto_callout
2484  xyz
2485  abcxyz
2486\= Expect no match
2487  abc
2488  abcxypqr
2489
2490/xyz/auto_callout,no_start_optimize
2491  abcxyz
2492\= Expect no match
2493  abc
2494  abcxypqr
2495
2496/(*NO_START_OPT)xyz/auto_callout
2497  abcxyz
2498
2499/(*NO_AUTO_POSSESS)a+b/B
2500
2501/xyz/auto_callout,no_start_optimize
2502  abcxyz
2503
2504/^"((?(?=[a])[^"])|b)*"$/auto_callout
2505    "ab"
2506
2507/^"((?(?=[a])[^"])|b)*"$/
2508    "ab"
2509
2510/^X(?5)(a)(?|(b)|(q))(c)(d)Y/
2511    XYabcdY
2512
2513/^X(?&N)(a)(?|(b)|(q))(c)(d)(?<N>Y)/
2514    XYabcdY
2515
2516/Xa{2,4}b/
2517    X\=ps
2518    Xa\=ps
2519    Xaa\=ps
2520    Xaaa\=ps
2521    Xaaaa\=ps
2522
2523/Xa{2,4}?b/
2524    X\=ps
2525    Xa\=ps
2526    Xaa\=ps
2527    Xaaa\=ps
2528    Xaaaa\=ps
2529
2530/Xa{2,4}+b/
2531    X\=ps
2532    Xa\=ps
2533    Xaa\=ps
2534    Xaaa\=ps
2535    Xaaaa\=ps
2536
2537/X\d{2,4}b/
2538    X\=ps
2539    X3\=ps
2540    X33\=ps
2541    X333\=ps
2542    X3333\=ps
2543
2544/X\d{2,4}?b/
2545    X\=ps
2546    X3\=ps
2547    X33\=ps
2548    X333\=ps
2549    X3333\=ps
2550
2551/X\d{2,4}+b/
2552    X\=ps
2553    X3\=ps
2554    X33\=ps
2555    X333\=ps
2556    X3333\=ps
2557
2558/X\D{2,4}b/
2559    X\=ps
2560    Xa\=ps
2561    Xaa\=ps
2562    Xaaa\=ps
2563    Xaaaa\=ps
2564
2565/X\D{2,4}?b/
2566    X\=ps
2567    Xa\=ps
2568    Xaa\=ps
2569    Xaaa\=ps
2570    Xaaaa\=ps
2571
2572/X\D{2,4}+b/
2573    X\=ps
2574    Xa\=ps
2575    Xaa\=ps
2576    Xaaa\=ps
2577    Xaaaa\=ps
2578
2579/X[abc]{2,4}b/
2580    X\=ps
2581    Xa\=ps
2582    Xaa\=ps
2583    Xaaa\=ps
2584    Xaaaa\=ps
2585
2586/X[abc]{2,4}?b/
2587    X\=ps
2588    Xa\=ps
2589    Xaa\=ps
2590    Xaaa\=ps
2591    Xaaaa\=ps
2592
2593/X[abc]{2,4}+b/
2594    X\=ps
2595    Xa\=ps
2596    Xaa\=ps
2597    Xaaa\=ps
2598    Xaaaa\=ps
2599
2600/X[^a]{2,4}b/
2601    X\=ps
2602    Xz\=ps
2603    Xzz\=ps
2604    Xzzz\=ps
2605    Xzzzz\=ps
2606
2607/X[^a]{2,4}?b/
2608    X\=ps
2609    Xz\=ps
2610    Xzz\=ps
2611    Xzzz\=ps
2612    Xzzzz\=ps
2613
2614/X[^a]{2,4}+b/
2615    X\=ps
2616    Xz\=ps
2617    Xzz\=ps
2618    Xzzz\=ps
2619    Xzzzz\=ps
2620
2621/(Y)X\1{2,4}b/
2622    YX\=ps
2623    YXY\=ps
2624    YXYY\=ps
2625    YXYYY\=ps
2626    YXYYYY\=ps
2627
2628/(Y)X\1{2,4}?b/
2629    YX\=ps
2630    YXY\=ps
2631    YXYY\=ps
2632    YXYYY\=ps
2633    YXYYYY\=ps
2634
2635/(Y)X\1{2,4}+b/
2636    YX\=ps
2637    YXY\=ps
2638    YXYY\=ps
2639    YXYYY\=ps
2640    YXYYYY\=ps
2641
2642/\++\KZ|\d+X|9+Y/startchar
2643    ++++123999\=ps
2644    ++++123999Y\=ps
2645    ++++Z1234\=ps
2646
2647/Z(*F)/
2648\= Expect no match
2649    Z\=ps
2650    ZA\=ps
2651
2652/Z(?!)/
2653\= Expect no match
2654    Z\=ps
2655    ZA\=ps
2656
2657/dog(sbody)?/
2658    dogs\=ps
2659    dogs\=ph
2660
2661/dog(sbody)??/
2662    dogs\=ps
2663    dogs\=ph
2664
2665/dog|dogsbody/
2666    dogs\=ps
2667    dogs\=ph
2668
2669/dogsbody|dog/
2670    dogs\=ps
2671    dogs\=ph
2672
2673/\bthe cat\b/
2674    the cat\=ps
2675    the cat\=ph
2676
2677/abc/
2678   abc\=ps
2679   abc\=ph
2680
2681/abc\K123/startchar
2682    xyzabc123pqr
2683    xyzabc12\=ps
2684    xyzabc12\=ph
2685
2686/(?<=abc)123/
2687    xyzabc123pqr
2688    xyzabc12\=ps
2689    xyzabc12\=ph
2690
2691/\babc\b/
2692    +++abc+++
2693    +++ab\=ps
2694    +++ab\=ph
2695
2696/(?&word)(?&element)(?(DEFINE)(?<element><[^m][^>]>[^<])(?<word>\w*+))/B
2697
2698/(?&word)(?&element)(?(DEFINE)(?<element><[^\d][^>]>[^<])(?<word>\w*+))/B
2699
2700/(ab)(x(y)z(cd(*ACCEPT)))pq/B
2701
2702/abc\K/aftertext,startchar
2703    abcdef
2704    abcdef\=notempty_atstart
2705    xyzabcdef\=notempty_atstart
2706\= Expect no match
2707    abcdef\=notempty
2708    xyzabcdef\=notempty
2709
2710/^(?:(?=abc)|abc\K)/aftertext,startchar
2711    abcdef
2712    abcdef\=notempty_atstart
2713\= Expect no match
2714    abcdef\=notempty
2715
2716/a?b?/aftertext
2717    xyz
2718    xyzabc
2719    xyzabc\=notempty
2720    xyzabc\=notempty_atstart
2721    xyz\=notempty_atstart
2722\= Expect no match
2723    xyz\=notempty
2724
2725/^a?b?/aftertext
2726    xyz
2727    xyzabc
2728\= Expect no match
2729    xyzabc\=notempty
2730    xyzabc\=notempty_atstart
2731    xyz\=notempty_atstart
2732    xyz\=notempty
2733
2734/^(?<name>a|b\g<name>c)/
2735    aaaa
2736    bacxxx
2737    bbaccxxx
2738    bbbacccxx
2739
2740/^(?<name>a|b\g'name'c)/
2741    aaaa
2742    bacxxx
2743    bbaccxxx
2744    bbbacccxx
2745
2746/^(a|b\g<1>c)/
2747    aaaa
2748    bacxxx
2749    bbaccxxx
2750    bbbacccxx
2751
2752/^(a|b\g'1'c)/
2753    aaaa
2754    bacxxx
2755    bbaccxxx
2756    bbbacccxx
2757
2758/^(a|b\g'-1'c)/
2759    aaaa
2760    bacxxx
2761    bbaccxxx
2762    bbbacccxx
2763
2764/(^(a|b\g<-1>c))/
2765    aaaa
2766    bacxxx
2767    bbaccxxx
2768    bbbacccxx
2769
2770/(?-i:\g<name>)(?i:(?<name>a))/
2771    XaaX
2772    XAAX
2773
2774/(?i:\g<name>)(?-i:(?<name>a))/
2775    XaaX
2776\= Expect no match
2777    XAAX
2778
2779/(?-i:\g<+1>)(?i:(a))/
2780    XaaX
2781    XAAX
2782
2783/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/
2784
2785/(?<n>a|b|c)\g<n>*/
2786   abc
2787   accccbbb
2788
2789/^X(?7)(a)(?|(b)|(q)(r)(s))(c)(d)(Y)/
2790    XYabcdY
2791
2792/(?<=b(?1)|zzz)(a)/
2793    xbaax
2794    xzzzax
2795
2796/(a)(?<=b\1)/
2797
2798/(a)(?<=b+(?1))/
2799
2800/(a+)(?<=b(?1))/
2801
2802/(a(?<=b(?1)))/
2803
2804/(?<=b(?1))xyz/
2805
2806/(?<=b(?1))xyz(b+)pqrstuvew/
2807
2808/(a|bc)\1/I
2809
2810/(a|bc)\1{2,3}/I
2811
2812/(a|bc)(?1)/I
2813
2814/(a|b\1)(a|b\1)/I
2815
2816/(a|b\1){2}/I
2817
2818/(a|bbbb\1)(a|bbbb\1)/I
2819
2820/(a|bbbb\1){2}/I
2821
2822/^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]/I
2823
2824/<tr([\w\W\s\d][^<>]{0,})><TD([\w\W\s\d][^<>]{0,})>([\d]{0,}\.)(.*)((<BR>([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><TD([\w\W\s\d][^<>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>/Iis
2825
2826"(?>.*/)foo"I
2827
2828/(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /Ix
2829
2830/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/Ii
2831
2832/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/I
2833
2834/<a[\s]+href[\s]*=[\s]*          # find <a href=
2835 ([\"\'])?                       # find single or double quote
2836 (?(1) (.*?)\1 | ([^\s]+))       # if quote found, match up to next matching
2837                                 # quote, otherwise match up to next space
2838/Iisx
2839
2840/^(?!:)                       # colon disallowed at start
2841  (?:                         # start of item
2842    (?: [0-9a-f]{1,4} |       # 1-4 hex digits or
2843    (?(1)0 | () ) )           # if null previously matched, fail; else null
2844    :                         # followed by colon
2845  ){1,7}                      # end item; 1-7 of them required
2846  [0-9a-f]{1,4} $             # final hex number at end of string
2847  (?(1)|.)                    # check that there was an empty component
2848  /Iix
2849
2850/(?|(?<a>A)|(?<a>B))/I
2851    AB\=copy=a
2852    BA\=copy=a
2853
2854/(?|(?<a>A)|(?<b>B))/
2855
2856/(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |
2857    b(?<quote> (?<apostrophe>')|(?<realquote>")) )
2858    (?('quote')[a-z]+|[0-9]+)/Ix,dupnames
2859    a"aaaaa
2860    b"aaaaa
2861\= Expect no match
2862    b"11111
2863    a"11111
2864
2865/^(?|(a)(b)(c)(?<D>d)|(?<D>e)) (?('D')X|Y)/IBx,dupnames
2866    abcdX
2867    eX
2868\= Expect no match
2869    abcdY
2870    ey
2871
2872/(?<A>a) (b)(c)  (?<A>d  (?(R&A)$ | (?4)) )/IBx,dupnames
2873    abcdd
2874\= Expect no match
2875    abcdde
2876
2877/abcd*/
2878    xxxxabcd\=ps
2879    xxxxabcd\=ph
2880
2881/abcd*/i
2882    xxxxabcd\=ps
2883    xxxxabcd\=ph
2884    XXXXABCD\=ps
2885    XXXXABCD\=ph
2886
2887/abc\d*/
2888    xxxxabc1\=ps
2889    xxxxabc1\=ph
2890
2891/(a)bc\1*/
2892    xxxxabca\=ps
2893    xxxxabca\=ph
2894
2895/abc[de]*/
2896    xxxxabcde\=ps
2897    xxxxabcde\=ph
2898
2899/(\3)(\1)(a)/allow_empty_class,match_unset_backref,dupnames
2900    cat
2901
2902/(\3)(\1)(a)/I,allow_empty_class,match_unset_backref,dupnames
2903    cat
2904
2905/(\3)(\1)(a)/I
2906\= Expect no match
2907    cat
2908
2909/i(?(DEFINE)(?<s>a))/I
2910    i
2911
2912/()i(?(1)a)/I
2913    ia
2914
2915/(?i)a(?-i)b|c/B
2916    XabX
2917    XAbX
2918    CcC
2919\= Expect no match
2920    XABX
2921
2922/(?i)a(?s)b|c/B
2923
2924/(?i)a(?s-i)b|c/B
2925
2926/^(ab(c\1)d|x){2}$/B
2927    xabcxd
2928
2929/^(?&t)*+(?(DEFINE)(?<t>.))$/B
2930
2931/^(?&t)*(?(DEFINE)(?<t>.))$/B
2932
2933# This one is here because Perl gives the match as "b" rather than "ab". I
2934# believe this to be a Perl bug.
2935
2936/(?>a\Kb)z|(ab)/
2937    ab\=startchar
2938
2939/(?P<L1>(?P<L2>0|)|(?P>L2)(?P>L1))/
2940    abcd
2941    0abc
2942
2943/abc(*MARK:)pqr/
2944
2945/abc(*:)pqr/
2946
2947/(*COMMIT:X)/B
2948
2949# This should, and does, fail. In Perl, it does not, which I think is a
2950# bug because replacing the B in the pattern by (B|D) does make it fail.
2951# Turning off Perl's optimization by inserting (??{""}) also makes it fail.
2952
2953/A(*COMMIT)B/aftertext,mark
2954\= Expect no match
2955    ACABX
2956
2957# These should be different, but in Perl they are not, which I think
2958# is a bug in Perl.
2959
2960/A(*THEN)B|A(*THEN)C/mark
2961    AC
2962
2963/A(*PRUNE)B|A(*PRUNE)C/mark
2964\= Expect no match
2965    AC
2966
2967# Mark names can be duplicated. Perl doesn't give a mark for this one,
2968# though PCRE2 does.
2969
2970/^A(*:A)B|^X(*:A)Y/mark
2971\= Expect no match
2972    XAQQ
2973
2974# COMMIT at the start of a pattern should be the same as an anchor. Perl
2975# optimizations defeat this. So does the PCRE2 optimization unless we disable
2976# it.
2977
2978/(*COMMIT)ABC/
2979    ABCDEFG
2980
2981/(*COMMIT)ABC/no_start_optimize
2982\= Expect no match
2983    DEFGABC
2984
2985/^(ab (c+(*THEN)cd) | xyz)/x
2986\= Expect no match
2987    abcccd
2988
2989/^(ab (c+(*PRUNE)cd) | xyz)/x
2990\= Expect no match
2991    abcccd
2992
2993/^(ab (c+(*FAIL)cd) | xyz)/x
2994\= Expect no match
2995    abcccd
2996
2997# Perl gets some of these wrong
2998
2999/(?>.(*ACCEPT))*?5/
3000    abcde
3001
3002/(.(*ACCEPT))*?5/
3003    abcde
3004
3005/(.(*ACCEPT))5/
3006    abcde
3007
3008/(.(*ACCEPT))*5/
3009    abcde
3010
3011/A\NB./B
3012    ACBD
3013\= Expect no match
3014    A\nB
3015    ACB\n
3016
3017/A\NB./Bs
3018    ACBD
3019    ACB\n
3020\= Expect no match
3021    A\nB
3022
3023/A\NB/newline=crlf
3024    A\nB
3025    A\rB
3026\= Expect no match
3027    A\r\nB
3028
3029/\R+b/B
3030
3031/\R+\n/B
3032
3033/\R+\d/B
3034
3035/\d*\R/B
3036
3037/\s*\R/B
3038    \x20\x0a
3039    \x20\x0d
3040    \x20\x0d\x0a
3041
3042/\S*\R/B
3043    a\x0a
3044
3045/X\h*\R/B
3046    X\x20\x0a
3047
3048/X\H*\R/B
3049    X\x0d\x0a
3050
3051/X\H+\R/B
3052    X\x0d\x0a
3053
3054/X\H++\R/B
3055\= Expect no match
3056    X\x0d\x0a
3057
3058/(?<=abc)def/
3059    abc\=ph
3060
3061/abc$/
3062    abc
3063    abc\=ps
3064    abc\=ph
3065
3066/abc$/m
3067    abc
3068    abc\n
3069    abc\=ph
3070    abc\n\=ph
3071    abc\=ps
3072    abc\n\=ps
3073
3074/abc\z/
3075    abc
3076    abc\=ps
3077    abc\=ph
3078
3079/abc\Z/
3080    abc
3081    abc\=ps
3082    abc\=ph
3083
3084/abc\b/
3085    abc
3086    abc\=ps
3087    abc\=ph
3088
3089/abc\B/
3090    abc\=ps
3091    abc\=ph
3092\= Expect no match
3093    abc
3094
3095/.+/
3096\= Bad offsets
3097    abc\=offset=4
3098    abc\=offset=-4
3099\= Valid data
3100    abc\=offset=0
3101    abc\=offset=1
3102    abc\=offset=2
3103\= Expect no match
3104    abc\=offset=3
3105
3106/^\cģ/
3107
3108/(?P<abn>(?P=abn)xxx)/B
3109
3110/(a\1z)/B
3111
3112/(?P<abn>(?P=abn)(?<badstufxxx)/B
3113
3114/(?P<abn>(?P=axn)xxx)/B
3115
3116/(?P<abn>(?P=axn)xxx)(?<axn>yy)/B
3117
3118# These tests are here because Perl gets the first one wrong.
3119
3120/(\R*)(.)/s
3121    \r\n
3122    \r\r\n\n\r
3123    \r\r\n\n\r\n
3124
3125/(\R)*(.)/s
3126    \r\n
3127    \r\r\n\n\r
3128    \r\r\n\n\r\n
3129
3130/((?>\r\n|\n|\x0b|\f|\r|\x85)*)(.)/s
3131    \r\n
3132    \r\r\n\n\r
3133    \r\r\n\n\r\n
3134
3135# -------------
3136
3137/^abc$/B
3138
3139/^abc$/Bm
3140
3141/^(a)*+(\w)/
3142    aaaaX
3143\= Expect no match
3144    aaaa
3145
3146/^(?:a)*+(\w)/
3147    aaaaX
3148\= Expect no match
3149    aaaa
3150
3151/(a)++1234/IB
3152
3153/([abc])++1234/I
3154
3155/(?<=(abc)+)X/
3156
3157/(^ab)/I
3158
3159/(^ab)++/I
3160
3161/(^ab|^)+/I
3162
3163/(^ab|^)++/I
3164
3165/(?:^ab)/I
3166
3167/(?:^ab)++/I
3168
3169/(?:^ab|^)+/I
3170
3171/(?:^ab|^)++/I
3172
3173/(.*ab)/I
3174
3175/(.*ab)++/I
3176
3177/(.*ab|.*)+/I
3178
3179/(.*ab|.*)++/I
3180
3181/(?:.*ab)/I
3182
3183/(?:.*ab)++/I
3184
3185/(?:.*ab|.*)+/I
3186
3187/(?:.*ab|.*)++/I
3188
3189/(?=a)[bcd]/I
3190
3191/((?=a))[bcd]/I
3192
3193/((?=a))+[bcd]/I
3194
3195/((?=a))++[bcd]/I
3196
3197/(?=a+)[bcd]/Ii
3198
3199/(?=a+?)[bcd]/Ii
3200
3201/(?=a++)[bcd]/Ii
3202
3203/(?=a{3})[bcd]/Ii
3204
3205/(abc)\1+/
3206
3207# Perl doesn't get these right IMO (the 3rd is PCRE2-specific)
3208
3209/(?1)(?:(b(*ACCEPT))){0}/
3210    b
3211
3212/(?1)(?:(b(*ACCEPT))){0}c/
3213    bc
3214\= Expect no match
3215    b
3216
3217/(?1)(?:((*ACCEPT))){0}c/
3218    c
3219    c\=notempty
3220
3221/^.*?(?(?=a)a|b(*THEN)c)/
3222\= Expect no match
3223    ba
3224
3225/^.*?(?(?=a)a|bc)/
3226    ba
3227
3228/^.*?(?(?=a)a(*THEN)b|c)/
3229\= Expect no match
3230    ac
3231
3232/^.*?(?(?=a)a(*THEN)b)c/
3233\= Expect no match
3234    ac
3235
3236/^.*?(a(*THEN)b)c/
3237\= Expect no match
3238    aabc
3239
3240/^.*? (?1) c (?(DEFINE)(a(*THEN)b))/x
3241    aabc
3242
3243/^.*?(a(*THEN)b|z)c/
3244    aabc
3245
3246/^.*?(z|a(*THEN)b)c/
3247    aabc
3248
3249# These are here because they are not Perl-compatible; the studying means the
3250# mark is not seen.
3251
3252/(*MARK:A)(*SKIP:B)(C|X)/mark
3253    C
3254\= Expect no match
3255    D
3256
3257/(*:A)A+(*SKIP:A)(B|Z)/mark
3258\= Expect no match
3259    AAAC
3260
3261# ----------------------------
3262
3263"(?=a*(*ACCEPT)b)c"
3264    c
3265    c\=notempty
3266
3267/(?1)c(?(DEFINE)((*ACCEPT)b))/
3268    c
3269    c\=notempty
3270
3271/(?>(*ACCEPT)b)c/
3272    c
3273\= Expect no match
3274    c\=notempty
3275
3276/(?:(?>(a)))+a%/allaftertext
3277    %aa%
3278
3279/(a)b|ac/allaftertext
3280    ac\=ovector=1
3281
3282/(a)(b)x|abc/allaftertext
3283     abc\=ovector=2
3284
3285/(a)bc|(a)(b)\2/
3286    abc\=ovector=1
3287    abc\=ovector=2
3288    aba\=ovector=1
3289    aba\=ovector=2
3290    aba\=ovector=3
3291    aba\=ovector=4
3292
3293/(?(DEFINE)(a(?2)|b)(b(?1)|a))(?:(?1)|(?2))/I
3294
3295/(a(?2)|b)(b(?1)|a)(?:(?1)|(?2))/I
3296
3297/(a(?2)|b)(b(?1)|a)(?1)(?2)/I
3298
3299/(abc)(?1)/I
3300
3301/(?:(foo)|(bar)|(baz))X/allcaptures
3302    bazfooX
3303    foobazbarX
3304    barfooX
3305    bazX
3306    foobarbazX
3307    bazfooX\=ovector=0
3308    bazfooX\=ovector=1
3309    bazfooX\=ovector=2
3310    bazfooX\=ovector=3
3311
3312/(?=abc){3}abc/B
3313
3314/(?=abc)+abc/B
3315
3316/(?=abc)++abc/B
3317
3318/(?=abc){0}xyz/B
3319
3320/(?=(a))?./B
3321
3322/(?=(a))??./B
3323
3324/^(?=(a)){0}b(?1)/B
3325
3326/(?(DEFINE)(a))?b(?1)/B
3327
3328/^(?=(?1))?[az]([abc])d/B
3329
3330/^(?!a){0}\w+/B
3331
3332/(?<=(abc))?xyz/B
3333
3334/[:a[:abc]b:]/B
3335
3336/^(a(*:A)(d|e(*:B))z|aeq)/auto_callout
3337    adz
3338    aez
3339    aeqwerty
3340
3341/.(*F)/
3342\= Expect no match
3343    abc\=ph
3344
3345/\btype\b\W*?\btext\b\W*?\bjavascript\b/I
3346
3347/\btype\b\W*?\btext\b\W*?\bjavascript\b|\burl\b\W*?\bshell:|<input\b.*?\btype\b\W*?\bimage\b|\bonkeyup\b\W*?\=/I
3348
3349/a(*SKIP)c|b(*ACCEPT)|/I,aftertext
3350    a
3351
3352/a(*SKIP)c|b(*ACCEPT)cd(*ACCEPT)|x/I
3353    ax
3354
3355'a*(*ACCEPT)b'aftertext
3356    abc\=notempty_atstart
3357    bbb\=notempty_atstart
3358\= Expect no match
3359    \=notempty_atstart
3360
3361/(*ACCEPT)a/I,aftertext
3362    bax
3363
3364/z(*ACCEPT)a/I,aftertext
3365    baxzbx
3366
3367/^(?>a+)(?>(z+))\w/B
3368    aaaazzzzb
3369\= Expect no match
3370    aazz
3371
3372/(.)(\1|a(?2))/
3373    bab
3374
3375/\1|(.)(?R)\1/
3376    cbbbc
3377
3378/(.)((?(1)c|a)|a(?2))/
3379\= Expect no match
3380    baa
3381
3382/(?P<abn>(?P=abn)xxx)/B
3383
3384/(a\1z)/B
3385
3386/^a\x41z/alt_bsux,allow_empty_class,match_unset_backref,dupnames
3387    aAz
3388\= Expect no match
3389    ax41z
3390
3391/^a[m\x41]z/alt_bsux,allow_empty_class,match_unset_backref,dupnames
3392    aAz
3393
3394/^a\x1z/alt_bsux,allow_empty_class,match_unset_backref,dupnames
3395    ax1z
3396
3397/^a\u0041z/alt_bsux,allow_empty_class,match_unset_backref,dupnames
3398    aAz
3399\= Expect no match
3400    au0041z
3401
3402/^a[m\u0041]z/alt_bsux,allow_empty_class,match_unset_backref,dupnames
3403    aAz
3404
3405/^a\u041z/alt_bsux,allow_empty_class,match_unset_backref,dupnames
3406    au041z
3407\= Expect no match
3408    aAz
3409
3410/^a\U0041z/alt_bsux,allow_empty_class,match_unset_backref,dupnames
3411    aU0041z
3412\= Expect no match
3413    aAz
3414
3415/^\u{7a}/alt_bsux
3416    u{7a}
3417\= Expect no match
3418    zoo
3419
3420/^\u{7a}/extra_alt_bsux
3421    zoo
3422
3423/\u{}/extra_alt_bsux
3424    u{}
3425
3426/\u{Q12}/extra_alt_bsux
3427    --u{Q12}--
3428
3429/\u{ 12}/extra_alt_bsux
3430    --u{ 12}--
3431
3432/\u{{3}}/extra_alt_bsux
3433    --u{{{}--
3434
3435/(?(?=c)c|d)++Y/B
3436
3437/(?(?=c)c|d)*+Y/B
3438
3439/a[\NB]c/
3440    aNc
3441
3442/a[B-\Nc]/
3443
3444/a[B\Nc]/
3445
3446/(a)(?2){0,1999}?(b)/
3447
3448/(a)(?(DEFINE)(b))(?2){0,1999}?(?2)/
3449
3450# This test, with something more complicated than individual letters, causes
3451# different behaviour in Perl. Perhaps it disables some optimization; no tag is
3452# passed back for the failures, whereas in PCRE2 there is a tag.
3453
3454/(A|P)(*:A)(B|P) | (X|P)(X|P)(*:B)(Y|P)/x,mark
3455    AABC
3456    XXYZ
3457\= Expect no match
3458    XAQQ
3459    XAQQXZZ
3460    AXQQQ
3461    AXXQQQ
3462
3463# Perl doesn't give marks for these, though it does if the alternatives are
3464# replaced by single letters.
3465
3466/(b|q)(*:m)f|a(*:n)w/mark
3467    aw
3468\= Expect no match
3469    abc
3470
3471/(q|b)(*:m)f|a(*:n)w/mark
3472    aw
3473\= Expect no match
3474    abc
3475
3476# After a partial match, the behaviour is as for a failure.
3477
3478/^a(*:X)bcde/mark
3479   abc\=ps
3480
3481# These are here because Perl doesn't return a mark, except for the first.
3482
3483/(?=(*:x))(q|)/aftertext,mark
3484    abc
3485
3486/(?=(*:x))((*:y)q|)/aftertext,mark
3487    abc
3488
3489/(?=(*:x))(?:(*:y)q|)/aftertext,mark
3490    abc
3491
3492/(?=(*:x))(?>(*:y)q|)/aftertext,mark
3493    abc
3494
3495/(?=a(*:x))(?!a(*:y)c)/aftertext,mark
3496    ab
3497
3498/(?=a(*:x))(?=a(*:y)c|)/aftertext,mark
3499    ab
3500
3501/(..)\1/
3502    ab\=ps
3503    aba\=ps
3504    abab\=ps
3505
3506/(..)\1/i
3507    ab\=ps
3508    abA\=ps
3509    aBAb\=ps
3510
3511/(..)\1{2,}/
3512    ab\=ps
3513    aba\=ps
3514    abab\=ps
3515    ababa\=ps
3516    ababab\=ps
3517    ababab\=ph
3518    abababa\=ps
3519    abababa\=ph
3520
3521/(..)\1{2,}/i
3522    ab\=ps
3523    aBa\=ps
3524    aBAb\=ps
3525    AbaBA\=ps
3526    abABAb\=ps
3527    aBAbaB\=ph
3528    abABabA\=ps
3529    abaBABa\=ph
3530
3531/(..)\1{2,}?x/i
3532    ab\=ps
3533    abA\=ps
3534    aBAb\=ps
3535    abaBA\=ps
3536    abAbaB\=ps
3537    abaBabA\=ps
3538    abAbABaBx\=ps
3539
3540/^(..)\1/
3541    aba\=ps
3542
3543/^(..)\1{2,3}x/
3544    aba\=ps
3545    ababa\=ps
3546    ababa\=ph
3547    abababx
3548    ababababx
3549
3550/^(..)\1{2,3}?x/
3551    aba\=ps
3552    ababa\=ps
3553    ababa\=ph
3554    abababx
3555    ababababx
3556
3557/^(..)(\1{2,3})ab/
3558    abababab
3559
3560/^\R/
3561    \r\=ps
3562    \r\=ph
3563
3564/^\R{2,3}x/
3565    \r\=ps
3566    \r\=ph
3567    \r\r\=ps
3568    \r\r\=ph
3569    \r\r\r\=ps
3570    \r\r\r\=ph
3571    \r\rx
3572    \r\r\rx
3573
3574/^\R{2,3}?x/
3575    \r\=ps
3576    \r\=ph
3577    \r\r\=ps
3578    \r\r\=ph
3579    \r\r\r\=ps
3580    \r\r\r\=ph
3581    \r\rx
3582    \r\r\rx
3583
3584/^\R?x/
3585    \r\=ps
3586    \r\=ph
3587    x
3588    \rx
3589
3590/^\R+x/
3591    \r\=ps
3592    \r\=ph
3593    \r\n\=ps
3594    \r\n\=ph
3595    \rx
3596
3597/^a$/newline=crlf
3598    a\r\=ps
3599    a\r\=ph
3600
3601/^a$/m,newline=crlf
3602    a\r\=ps
3603    a\r\=ph
3604
3605/^(a$|a\r)/newline=crlf
3606    a\r\=ps
3607    a\r\=ph
3608
3609/^(a$|a\r)/m,newline=crlf
3610    a\r\=ps
3611    a\r\=ph
3612
3613/./newline=crlf
3614    \r\=ps
3615    \r\=ph
3616
3617/.{2,3}/newline=crlf
3618    \r\=ps
3619    \r\=ph
3620    \r\r\=ps
3621    \r\r\=ph
3622    \r\r\r\=ps
3623    \r\r\r\=ph
3624
3625/.{2,3}?/newline=crlf
3626    \r\=ps
3627    \r\=ph
3628    \r\r\=ps
3629    \r\r\=ph
3630    \r\r\r\=ps
3631    \r\r\r\=ph
3632
3633"AB(C(D))(E(F))?(?(?=\2)(?=\4))"
3634    ABCDGHI\=ovector=01
3635
3636# These are all run as real matches in test 1; here we are just checking the
3637# settings of the anchored and startline bits.
3638
3639/(?>.*?a)(?<=ba)/I
3640
3641/(?:.*?a)(?<=ba)/I
3642
3643/.*?a(*PRUNE)b/I
3644
3645/.*?a(*PRUNE)b/Is
3646
3647/^a(*PRUNE)b/Is
3648
3649/.*?a(*SKIP)b/I
3650
3651/(?>.*?a)b/Is
3652
3653/(?>.*?a)b/I
3654
3655/(?>^a)b/Is
3656
3657/(?>.*?)(?<=(abcd)|(wxyz))/I
3658
3659/(?>.*)(?<=(abcd)|(wxyz))/I
3660
3661"(?>.*)foo"I
3662
3663"(?>.*?)foo"I
3664
3665/(?>^abc)/Im
3666
3667/(?>.*abc)/Im
3668
3669/(?:.*abc)/Im
3670
3671/(?:(a)+(?C1)bb|aa(?C2)b)/
3672    aab\=callout_capture
3673
3674/(?:(a)++(?C1)bb|aa(?C2)b)/
3675    aab\=callout_capture
3676
3677/(?:(?>(a))(?C1)bb|aa(?C2)b)/
3678    aab\=callout_capture
3679
3680/(?:(?1)(?C1)x|ab(?C2))((a)){0}/
3681    aab\=callout_capture
3682
3683/(?1)(?C1)((a)(?C2)){0}/
3684    aab\=callout_capture
3685
3686/(?:(a)+(?C1)bb|aa(?C2)b)++/
3687    aab\=callout_capture
3688    aab\=callout_capture,ovector=1
3689
3690/(ab)x|ab/
3691    ab\=ovector=0
3692    ab\=ovector=1
3693
3694/(?<=123)(*MARK:xx)abc/mark
3695    xxxx123a\=ph
3696    xxxx123a\=ps
3697
3698/123\Kabc/startchar
3699    xxxx123a\=ph
3700    xxxx123a\=ps
3701
3702/^(?(?=a)aa|bb)/auto_callout
3703    bb
3704
3705/(?C1)^(?C2)(?(?C99)(?=(?C3)a(?C4))(?C5)a(?C6)a(?C7)|(?C8)b(?C9)b(?C10))(?C11)/
3706    bb
3707
3708# Perl seems to have a bug with this one.
3709
3710/aaaaa(*COMMIT)(*PRUNE)b|a+c/
3711    aaaaaac
3712
3713# Here are some that Perl treats differently because of the way it handles
3714# backtracking verbs.
3715
3716/(?!a(*COMMIT)b)ac|ad/
3717     ac
3718     ad
3719
3720/^(?!a(*THEN)b|ac)../
3721     ad
3722\= Expect no match
3723     ac
3724
3725/^(?=a(*THEN)b|ac)/
3726    ac
3727
3728/\A.*?(?:a|b(*THEN)c)/
3729    ba
3730
3731/\A.*?(?:a|b(*THEN)c)++/
3732    ba
3733
3734/\A.*?(?:a|b(*THEN)c|d)/
3735    ba
3736
3737/(?:(a(*MARK:X)a+(*SKIP:X)b)){0}(?:(?1)|aac)/
3738    aac
3739
3740/\A.*?(a|b(*THEN)c)/
3741    ba
3742
3743/^(A(*THEN)B|A(*THEN)D)/
3744    AD
3745
3746/(?!b(*THEN)a)bn|bnn/
3747    bnn
3748
3749/(?(?=b(*SKIP)a)bn|bnn)/
3750    bnn
3751
3752/(?=b(*THEN)a|)bn|bnn/
3753    bnn
3754
3755# This test causes a segfault with Perl 5.18.0
3756
3757/^(?=(a)){0}b(?1)/
3758    backgammon
3759
3760/(?|(?<n>f)|(?<n>b))/I,dupnames
3761
3762/(?<a>abc)(?<a>z)\k<a>()/IB,dupnames
3763
3764/a*[bcd]/B
3765
3766/[bcd]*a/B
3767
3768# A complete set of tests for auto-possessification of character types, but
3769# omitting \C because it might be disabled (it has its own tests).
3770
3771/\D+\D \D+\d \D+\S \D+\s \D+\W \D+\w \D+. \D+\R \D+\H \D+\h \D+\V \D+\v \D+\Z \D+\z \D+$/Bx
3772
3773/\d+\D \d+\d \d+\S \d+\s \d+\W \d+\w \d+. \d+\R \d+\H \d+\h \d+\V \d+\v \d+\Z \d+\z \d+$/Bx
3774
3775/\S+\D \S+\d \S+\S \S+\s \S+\W \S+\w \S+. \S+\R \S+\H \S+\h \S+\V \S+\v \S+\Z \S+\z \S+$/Bx
3776
3777/\s+\D \s+\d \s+\S \s+\s \s+\W \s+\w \s+. \s+\R \s+\H \s+\h \s+\V \s+\v \s+\Z \s+\z \s+$/Bx
3778
3779/\W+\D \W+\d \W+\S \W+\s \W+\W \W+\w \W+. \W+\R \W+\H \W+\h \W+\V \W+\v \W+\Z \W+\z \W+$/Bx
3780
3781/\w+\D \w+\d \w+\S \w+\s \w+\W \w+\w \w+. \w+\R \w+\H \w+\h \w+\V \w+\v \w+\Z \w+\z \w+$/Bx
3782
3783/\R+\D \R+\d \R+\S \R+\s \R+\W \R+\w \R+. \R+\R \R+\H \R+\h \R+\V \R+\v \R+\Z \R+\z \R+$/Bx
3784
3785/\H+\D \H+\d \H+\S \H+\s \H+\W \H+\w \H+. \H+\R \H+\H \H+\h \H+\V \H+\v \H+\Z \H+\z \H+$/Bx
3786
3787/\h+\D \h+\d \h+\S \h+\s \h+\W \h+\w \h+. \h+\R \h+\H \h+\h \h+\V \h+\v \h+\Z \h+\z \h+$/Bx
3788
3789/\V+\D \V+\d \V+\S \V+\s \V+\W \V+\w \V+. \V+\R \V+\H \V+\h \V+\V \V+\v \V+\Z \V+\z \V+$/Bx
3790
3791/\v+\D \v+\d \v+\S \v+\s \v+\W \v+\w \v+. \v+\R \v+\H \v+\h \v+\V \v+\v \v+\Z \v+\z \v+$/Bx
3792
3793/ a+\D  a+\d  a+\S  a+\s  a+\W  a+\w  a+.  a+\R  a+\H  a+\h  a+\V  a+\v  a+\Z  a+\z  a+$/Bx
3794
3795/\n+\D \n+\d \n+\S \n+\s \n+\W \n+\w \n+. \n+\R \n+\H \n+\h \n+\V \n+\v \n+\Z \n+\z \n+$/Bx
3796
3797/ .+\D  .+\d  .+\S  .+\s  .+\W  .+\w  .+.  .+\R  .+\H  .+\h  .+\V  .+\v  .+\Z  .+\z  .+$/Bx
3798
3799/ .+\D  .+\d  .+\S  .+\s  .+\W  .+\w  .+.  .+\R  .+\H  .+\h  .+\V  .+\v  .+\Z  .+\z  .+$/Bsx
3800
3801/ \D+$  \d+$  \S+$  \s+$  \W+$  \w+$  \R+$  \H+$  \h+$  \V+$ \v+$  a+$   \n+$  .+$  .+$/Bmx
3802
3803/(?=a+)a(a+)++a/B
3804
3805/a+(bb|cc)a+(?:bb|cc)a+(?>bb|cc)a+(?:bb|cc)+a+(aa)a+(?:bb|aa)/B
3806
3807/a+(bb|cc)?#a+(?:bb|cc)??#a+(?:bb|cc)?+#a+(?:bb|cc)*#a+(bb|cc)?a#a+(?:aa)?/B
3808
3809/a+(?:bb)?a#a+(?:|||)#a+(?:|b)a#a+(?:|||)?a/B
3810
3811/[ab]*/B
3812    aaaa
3813
3814/[ab]*?/B
3815    aaaa
3816
3817/[ab]?/B
3818    aaaa
3819
3820/[ab]??/B
3821    aaaa
3822
3823/[ab]+/B
3824    aaaa
3825
3826/[ab]+?/B
3827    aaaa
3828
3829/[ab]{2,3}/B
3830    aaaa
3831
3832/[ab]{2,3}?/B
3833    aaaa
3834
3835/[ab]{2,}/B
3836    aaaa
3837
3838/[ab]{2,}?/B
3839    aaaa
3840
3841/\d+\s{0,5}=\s*\S?=\w{0,4}\W*/B
3842
3843/[a-d]{5,12}[e-z0-9]*#[^a-z]+[b-y]*a[2-7]?[^0-9a-z]+/B
3844
3845/[a-z]*\s#[ \t]?\S#[a-c]*\S#[C-G]+?\d#[4-8]*\D#[4-9,]*\D#[!$]{0,5}\w#[M-Xf-l]+\W#[a-c,]?\W/B
3846
3847/a+(aa|bb)*c#a*(bb|cc)*a#a?(bb|cc)*d#[a-f]*(g|hh)*f/B
3848
3849/[a-f]*(g|hh|i)*i#[a-x]{4,}(y{0,6})*y#[a-k]+(ll|mm)+n/B
3850
3851/[a-f]*(?>gg|hh)+#[a-f]*(?>gg|hh)?#[a-f]*(?>gg|hh)*a#[a-f]*(?>gg|hh)*h/B
3852
3853/[a-c]*d/IB
3854
3855/[a-c]+d/IB
3856
3857/[a-c]?d/IB
3858
3859/[a-c]{4,6}d/IB
3860
3861/[a-c]{0,6}d/IB
3862
3863# End of special auto-possessive tests
3864
3865/^A\o{1239}B/
3866    A\123B
3867
3868/^A\oB/
3869
3870/^A\x{zz}B/
3871
3872/^A\x{12Z/
3873
3874/^A\x{/
3875
3876/[ab]++/B,no_auto_possess
3877
3878/[^ab]*+/B,no_auto_possess
3879
3880/a{4}+/B,no_auto_possess
3881
3882/a{4}+/Bi,no_auto_possess
3883
3884/[a-[:digit:]]+/
3885
3886/[A-[:digit:]]+/
3887
3888/[a-[.xxx.]]+/
3889
3890/[a-[=xxx=]]+/
3891
3892/[a-[!xxx!]]+/
3893
3894/[A-[!xxx!]]+/
3895    A]]]
3896
3897/[a-\d]+/
3898
3899/(?<0abc>xx)/
3900
3901/(?&1abc)xx(?<1abc>y)/
3902
3903/(?<ab-cd>xx)/
3904
3905/(?'0abc'xx)/
3906
3907/(?P<0abc>xx)/
3908
3909/\k<5ghj>/
3910
3911/\k'5ghj'/
3912
3913/\k{2fgh}/
3914
3915/(?P=8yuki)/
3916
3917/\g{4df}/
3918
3919/(?&1abc)xx(?<1abc>y)/
3920
3921/(?P>1abc)xx(?<1abc>y)/
3922
3923/\g'3gh'/
3924
3925/\g<5fg>/
3926
3927/(?(<4gh>)abc)/
3928
3929/(?('4gh')abc)/
3930
3931/(?(4gh)abc)/
3932
3933/(?(R&6yh)abc)/
3934
3935/(((a\2)|(a*)\g<-1>))*a?/B
3936
3937# Test the ugly "start or end of word" compatibility syntax.
3938
3939/[[:<:]]red[[:>:]]/B
3940    little red riding hood
3941    a /red/ thing
3942    red is a colour
3943    put it all on red
3944\= Expect no match
3945    no reduction
3946    Alfred Winifred
3947
3948/[a[:<:]] should give error/
3949
3950/(?=ab\K)/aftertext,allow_lookaround_bsk
3951    abcd\=startchar
3952
3953/abcd/newline=lf,firstline
3954\= Expect no match
3955    xx\nxabcd
3956
3957# Test stack guard external calls.
3958
3959/(((a)))/stackguard=1
3960
3961/(((a)))/stackguard=2
3962
3963/(((a)))/stackguard=3
3964
3965/(((((a)))))/
3966
3967# End stack guard tests
3968
3969/^\w+(?>\s*)(?<=\w)/B
3970
3971/\othing/
3972
3973/\o{}/
3974
3975/\o{whatever}/
3976
3977/\xthing/
3978
3979/\x{}/
3980
3981/\x{whatever}/
3982
3983/A\8B/
3984
3985/A\9B/
3986
3987# This one is here because Perl fails to match "12" for this pattern when the $
3988# is present.
3989
3990/^(?(?=abc)\w{3}:|\d\d)$/
3991    abc:
3992    12
3993\= Expect no match
3994    123
3995    xyz
3996
3997# Perl gets this one wrong, giving "a" as the after text for ca and failing to
3998# match for cd.
3999
4000/(?(?=ab)ab)/aftertext
4001    abxxx
4002    ca
4003    cd
4004
4005# This should test both paths for processing OP_RECURSE.
4006
4007/(?(R)a+|(?R)b)/
4008    aaaabcde
4009    aaaabcde\=ovector=100
4010
4011/a*?b*?/
4012    ab
4013
4014/(*NOTEMPTY)a*?b*?/
4015    ab
4016    ba
4017    cb
4018
4019/(*NOTEMPTY_ATSTART)a*?b*?/aftertext
4020    ab
4021    cdab
4022
4023/(?(VERSION>=10.0)yes|no)/I
4024    yesno
4025
4026/(?(VERSION>=10.04)yes|no)/
4027    yesno
4028
4029/(?(VERSION=8)yes){3}/BI,aftertext
4030    yesno
4031
4032/(?(VERSION=8)yes|no){3}/I
4033    yesnononoyes
4034\= Expect no match
4035    yesno
4036
4037/(?:(?<VERSION>abc)|xyz)(?(VERSION)yes|no)/I
4038    abcyes
4039    xyzno
4040\= Expect no match
4041    abcno
4042    xyzyes
4043
4044/(?(VERSION<10)yes|no)/
4045
4046/(?(VERSION>10)yes|no)/
4047
4048/(?(VERSION>=10.0.0)yes|no)/
4049
4050/(?(VERSION=10.101)yes|no)/
4051
4052/abcd/I
4053
4054/abcd/I,no_start_optimize
4055
4056/(|ab)*?d/I
4057   abd
4058   xyd
4059
4060/(|ab)*?d/I,no_start_optimize
4061   abd
4062   xyd
4063
4064/\k<A>*(?<A>aa)(?<A>bb)/match_unset_backref,dupnames
4065    aabb
4066
4067/(((((a)))))/parens_nest_limit=2
4068
4069/abc/replace=XYZ
4070    123123
4071    123abc123
4072    123abc123abc123
4073    123123\=zero_terminate
4074    123abc123\=zero_terminate
4075    123abc123abc123\=zero_terminate
4076
4077/abc/g,replace=XYZ
4078    123abc123
4079    123abc123abc123
4080
4081/abc/replace=X$$Z
4082    123abc123
4083
4084/abc/g,replace=X$$Z
4085    123abc123abc123
4086
4087/a(b)c(d)e/replace=X$1Y${2}Z
4088    "abcde"
4089
4090/a(b)c(d)e/replace=X$1Y${2}Z,global
4091    "abcde-abcde"
4092
4093/a(?<ONE>b)c(?<TWO>d)e/replace=X$ONE+${TWO}Z
4094    "abcde"
4095
4096/a(?<ONE>b)c(?<TWO>d)e/g,replace=X$ONE+${TWO}Z
4097    "abcde-abcde-"
4098
4099/abc/replace=a$++
4100    123abc
4101
4102/abc/replace=a$bad
4103    123abc
4104
4105/abc/replace=a${A234567890123456789_123456789012}z
4106    123abc
4107
4108/abc/replace=a${A23456789012345678901234567890123}z
4109    123abc
4110
4111/abc/replace=a${bcd
4112    123abc
4113
4114/abc/replace=a${b+d}z
4115    123abc
4116
4117/abc/replace=[10]XYZ
4118    123abc123
4119
4120/abc/replace=[9]XYZ
4121    123abc123
4122
4123/abc/replace=xyz
4124    1abc2\=partial_hard
4125
4126/abc/replace=xyz
4127    123abc456
4128    123abc456\=replace=pqr
4129    123abc456abc789
4130    123abc456abc789\=g
4131
4132/(?<=abc)(|def)/g,replace=<$0>
4133    123abcxyzabcdef789abcpqr
4134
4135/./replace=$0
4136    a
4137
4138/(.)(.)/replace=$2+$1
4139    abc
4140
4141/(?<A>.)(?<B>.)/replace=$B+$A
4142    abc
4143
4144/(.)(.)/g,replace=$2$1
4145    abcdefgh
4146
4147/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/g,replace=${*MARK}
4148    apple lemon blackberry
4149    apple strudel
4150    fruitless
4151
4152/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/replace=${*MARK} sauce,
4153    apple lemon blackberry
4154
4155/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/g,replace=<$*MARK>
4156    apple lemon blackberry
4157    apple strudel
4158    fruitless
4159
4160/(*:pear)apple/g,replace=${*MARKING}
4161    apple lemon blackberry
4162
4163/(*:pear)apple/g,replace=${*MARK-time
4164    apple lemon blackberry
4165
4166/(*:pear)apple/g,replace=${*mark}
4167    apple lemon blackberry
4168
4169/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/g,replace=<$*MARKET>
4170    apple lemon blackberry
4171
4172/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/g,replace=[22]${*MARK}
4173    apple lemon blackberry
4174    apple lemon blackberry\=substitute_overflow_length
4175
4176/(*:pear)apple|(*:orange)lemon|(*:strawberry)blackberry/g,replace=[23]${*MARK}
4177    apple lemon blackberry
4178
4179/abc/
4180    123abc123\=replace=[9]XYZ
4181    123abc123\=substitute_overflow_length,replace=[9]XYZ
4182    123abc123\=substitute_overflow_length,replace=[6]XYZ
4183    123abc123\=substitute_overflow_length,replace=[1]XYZ
4184    123abc123\=substitute_overflow_length,replace=[0]XYZ
4185
4186/a(b)c/
4187    123abc123\=replace=[9]x$1z
4188    123abc123\=substitute_overflow_length,replace=[9]x$1z
4189    123abc123\=substitute_overflow_length,replace=[6]x$1z
4190    123abc123\=substitute_overflow_length,replace=[1]x$1z
4191    123abc123\=substitute_overflow_length,replace=[0]x$1z
4192
4193"((?=(?(?=(?(?=(?(?=()))))))))"
4194    a
4195
4196"(?(?=)==)(((((((((?=)))))))))"
4197\= Expect no match
4198    a
4199
4200/(a)(b)|(c)/
4201    XcX\=ovector=2,get=1,get=2,get=3,get=4,getall
4202
4203/x(?=ab\K)/allow_lookaround_bsk
4204    xab\=get=0
4205    xab\=copy=0
4206    xab\=getall
4207
4208/(?<A>a)|(?<A>b)/dupnames
4209    a\=ovector=1,copy=A,get=A,get=2
4210    a\=ovector=2,copy=A,get=A,get=2
4211    b\=ovector=2,copy=A,get=A,get=2
4212
4213/a(b)c(d)/
4214    abc\=ph,copy=0,copy=1,getall
4215
4216/^abc/info
4217
4218/^abc/info,no_dotstar_anchor
4219
4220/.*\d/info,auto_callout
4221\= Expect no match
4222    aaa
4223
4224/.*\d/info,no_dotstar_anchor,auto_callout
4225\= Expect no match
4226    aaa
4227
4228/.*\d/dotall,info
4229
4230/.*\d/dotall,no_dotstar_anchor,info
4231
4232/(*NO_DOTSTAR_ANCHOR)(?s).*\d/info
4233
4234'^(?:(a)|b)(?(1)A|B)'
4235    aA123\=ovector=1
4236    aA123\=ovector=2
4237
4238'^(?:(?<AA>a)|b)(?(<AA>)A|B)'
4239    aA123\=ovector=1
4240    aA123\=ovector=2
4241
4242'^(?<AA>)(?:(?<AA>a)|b)(?(<AA>)A|B)'dupnames
4243    aA123\=ovector=1
4244    aA123\=ovector=2
4245    aA123\=ovector=3
4246
4247'^(?:(?<AA>X)|)(?:(?<AA>a)|b)\k{AA}'dupnames
4248    aa123\=ovector=1
4249    aa123\=ovector=2
4250    aa123\=ovector=3
4251
4252/(?<N111>(?J)(?<N111>1(111111)11|)1|1|)(?(<N111>)1)/
4253
4254/(?<N>(?J)(?<N>))(?-J)\k<N>/
4255
4256# Quantifiers are not allowed on condition assertions, but are otherwise
4257# OK in conditions.
4258
4259/(?(?=0)?)+/
4260
4261/(?(?=0)(?=00)?00765)/
4262     00765
4263
4264/(?(?=0)(?=00)?00765|(?!3).56)/
4265     00765
4266     456
4267\= Expect no match
4268     356
4269
4270'^(a)*+(\w)'
4271    g
4272    g\=ovector=1
4273
4274'^(?:a)*+(\w)'
4275    g
4276    g\=ovector=1
4277
4278# These two pattern showeds up compile-time bugs
4279
4280"((?2){0,1999}())?"
4281
4282/((?+1)(\1))/B
4283
4284# Callouts with string arguments
4285
4286/a(?C"/
4287
4288/a(?C"a/
4289
4290/a(?C"a"/
4291
4292/a(?C"a"bcde(?C"b")xyz/
4293
4294/a(?C"a)b""c")/B
4295
4296/ab(?C" any text with spaces ")cde/B
4297    abcde
4298    12abcde
4299
4300/^a(b)c(?C1)def/
4301      abcdef
4302
4303/^a(b)c(?C"AB")def/
4304      abcdef
4305
4306/^a(b)c(?C1)def/
4307      abcdef\=callout_capture
4308
4309/^a(b)c(?C{AB})def/B
4310      abcdef\=callout_capture
4311
4312/(?C`a``b`)(?C'a''b')(?C"a""b")(?C^a^^b^)(?C%a%%b%)(?C#a##b#)(?C$a$$b$)(?C{a}}b})/B,callout_info
4313
4314/(?:a(?C`code`)){3}/B
4315
4316/^(?(?C25)(?=abc)abcd|xyz)/B,callout_info
4317    abcdefg
4318    xyz123
4319
4320/^(?(?C$abc$)(?=abc)abcd|xyz)/B
4321    abcdefg
4322    xyz123
4323
4324/^ab(?C'first')cd(?C"second")ef/
4325    abcdefg
4326
4327/(?:a(?C`code`)){3}X/
4328    aaaXY
4329
4330# Binary zero in callout string
4331#  a  (  ?  C  '  x     z  '  )  b
4332/ 61 28 3f 43 27 78 00 7a 27 29 62/hex,callout_info
4333    abcdefgh
4334
4335/(?(?!)^)/
4336
4337/(?(?!)a|b)/
4338    bbb
4339\= Expect no match
4340    aaa
4341
4342# JIT gives a different error message for the infinite recursion
4343
4344"(*NO_JIT)((?2)+)((?1)){"
4345    abcd{
4346
4347# Perl fails to diagnose the absence of an assertion
4348
4349"(?(?<E>.*!.*)?)"
4350
4351"X((?2)()*+){2}+"B
4352
4353"X((?2)()*+){2}"B
4354
4355/(?<=\bABQ(3(?-7)))/
4356
4357/(?<=\bABQ(3(?+7)))/
4358
4359";(?<=()((?3))((?2)))"
4360
4361# Perl loops on this (PCRE2 used to!)
4362
4363/(?<=\Ka)/g,aftertext,allow_lookaround_bsk
4364    aaaaa
4365
4366/(?<=\Ka)/altglobal,aftertext,allow_lookaround_bsk
4367    aaaaa
4368
4369/((?2){73}(?2))((?1))/info
4370
4371/abc/
4372\= Expect no match
4373    \[9x!xxx(]{9999}
4374
4375/(abc)*/
4376    \[abc]{5}
4377
4378/^/gm
4379    \n\n\n
4380
4381/^/gm,alt_circumflex
4382    \n\n\n
4383
4384/((((((((x))))))))\81/
4385    xx1
4386
4387/((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((x))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))\80/
4388    xx
4389
4390/\80/
4391
4392/A\8B\9C/
4393    A8B9C
4394
4395/(?x:((?'a')) # comment (with parentheses) and | vertical
4396(?-x:#not a comment (?'b')) # this is a comment ()
4397(?'c')) # not a comment (?'d')/info
4398
4399/(?|(?'a')(2)(?'b')|(?'a')(?'a')(3))/I,dupnames
4400    A23B
4401    B32A
4402
4403# These are some patterns that used to cause buffer overflows or other errors
4404# while compiling.
4405
4406/.((?2)(?R)|\1|$)()/B
4407
4408/.((?3)(?R)()(?2)|\1|$)()/B
4409
4410/(\9*+(?2);\3++()2|)++{/
4411
4412/\V\x85\9*+((?2)\3++()2)*:2/
4413
4414/(((?(R)){0,2}) (?'x'((?'R')((?'R')))))/dupnames
4415
4416/(((?(X)){0,2}) (?'x'((?'X')((?'X')))))/dupnames
4417
4418/(((?(R)){0,2}) (?'x'((?'X')((?'R')))))/
4419
4420"(?J)(?'d'(?'d'\g{d}))"
4421
4422"(?=!((?2)(?))({8(?<=(?1){29}8bbbb\x16\xd\xc6^($(\xa9H4){4}h}?1)B))\x15')"
4423
4424/A(?'')Z/
4425
4426"(?J:(?|(?'R')(\k'R')|((?'R'))))"
4427
4428/(?<=|(\,\$(?73591620449005828816)\xa8.{7}){6}\x09)/
4429
4430/^(?:(?(1)x|)+)+$()/B
4431
4432/[[:>:]](?<)/
4433
4434/((?x)(*:0))#(?'/
4435
4436/(?C$[$)(?<]/
4437
4438/(?C$)$)(?<]/
4439
4440/(?(R))*+/B
4441    abcd
4442
4443/((?x)(?#))#(?'/
4444
4445/((?x)(?#))#(?'abc')/I
4446
4447/[[:\\](?<[::]/
4448
4449/[[:\\](?'abc')[a:]/I
4450
4451"[[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[:::::::::::::::::[[.\xe8Nq\xffq\xff\xe0\x2|||::Nq\xffq\xff\xe0\x6\x2|||::[[[:[::::::[[[[[::::::::[:[[[:[:::[[[[[[[[[[[[[[:::E[[[:[:[[:[:::[[:::E[[[:[:[[:'[:::::E[[[:[::::::[[[:[[[[[[[::E[[[:[::::::[[[:[[[[[[[[:[[::[::::[[:::::::[[:[[[[[[[:[[::[:[[:[~"
4452
4453/()(?(R)0)*+/B
4454
4455/(?R-:(?</
4456
4457/(?R-:(?<)/
4458
4459/(?(?C{\Q})(?!(?'/
4460
4461/(?(?C{\Q})(?!(?'abc')))/I
4462
4463/(?1){3918}(((((0(\k'R'))))(?J)(?'R'(?'R'\3){99})))/I
4464
4465/(?|(aaa)|(b))\g{1}/I
4466
4467/(?|(aaa)|(b))(?1)/I
4468
4469/(?|(aaa)|(b))/I
4470
4471/(?|(?'a'aaa)|(?'a'b))\k'a'/I
4472
4473/(?|(?'a'aaa)|(?'a'b))(?'a'cccc)\k'a'/I,dupnames
4474
4475/ab{3cd/
4476    ab{3cd
4477
4478/ab{3,cd/
4479    ab{3,cd
4480
4481/ab{3,4a}cd/
4482    ab{3,4a}cd
4483
4484/{4,5a}bc/
4485    {4,5a}bc
4486
4487/\x0{ab}/
4488    \0{ab}
4489
4490/^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-02}Z/
4491    ababababbbabZXXXX
4492
4493/.*?a(*PRUNE)b/
4494    aab
4495
4496/.*?a(*PRUNE)b/s
4497    aab
4498
4499/^a(*PRUNE)b/s
4500\= Expect no match
4501    aab
4502
4503/.*?a(*SKIP)b/
4504    aab
4505
4506/(?(8000000000/
4507
4508/((?(R8000000000)))/
4509
4510/0(?0)|(1)(*THEN)(*SKIP:0)(*FAIL)/
4511\= Expect no match
4512    01
4513
4514/(?(1)()\983040\2)/
4515
4516/(*LIMIT_MATCH=)abc/
4517
4518/(*CRLF)(*LIMIT_MATCH=)abc/
4519
4520/(?:ab)?(?:ab)(?:ab)/
4521    abab
4522    ababab
4523\= Expect no match
4524    aba
4525
4526/((*MARK:A))++a(*SKIP:B)b/
4527\= Expect no match
4528    aacb
4529
4530/(*MARK:a\zb)z/alt_verbnames
4531
4532/(*:ab\t(d\)c)xxx/
4533
4534/(*:ab\t(d\)c)xxx/alt_verbnames,mark
4535    cxxxz
4536
4537/(*:A\Qxx)x\EB)x/alt_verbnames,mark
4538    x
4539
4540/(*:A\ExxxB)x/alt_verbnames,mark
4541    x
4542
4543/(*: A \ and #comment
4544     \ B)x/x,alt_verbnames,mark
4545    x
4546
4547/(*: A \ and #comment
4548     \ B)x/alt_verbnames,mark
4549    x
4550
4551/(*: A \ and #comment
4552     \ B)x/x,mark
4553    x
4554
4555/(*: A \ and #comment
4556     \ B)x/mark
4557    x
4558
4559/(*:A
4560B)x/alt_verbnames,mark
4561    x
4562
4563/(*:abc\Qpqr)/alt_verbnames
4564
4565/abc/use_offset_limit
4566    1234abcde\=offset_limit=100
4567    1234abcde\=offset_limit=9
4568    1234abcde\=offset_limit=4
4569    1234abcde\=offset_limit=4,offset=4
4570\= Expect no match
4571    1234abcde\=offset_limit=4,offset=5
4572    1234abcde\=offset_limit=3
4573
4574/(?<=abc)/use_offset_limit
4575    1234abc\=offset_limit=7
4576\= Expect no match
4577    1234abc\=offset_limit=6
4578
4579/A/g,replace=-,use_offset_limit
4580    XAXAXAXAXA\=offset_limit=4
4581
4582/abc/
4583\= Expect error
4584    1234abcde\=offset_limit=4
4585
4586/^\w/m,use_offset_limit
4587    \n..\naa\=offset_limit=3
4588    \n..\naa\=offset_limit=4
4589
4590/abcd/null_context
4591    abcd\=null_context
4592\= Expect error - not allowed together
4593    abcd\=null_context,find_limits
4594    abcd\=allusedtext,startchar
4595
4596/abcd/replace=w\rx\x82y\o{333}z(\Q12\$34$$\x34\E5$$),substitute_extended
4597    abcd
4598
4599/abcd/replace=w\rx\x82y\o{333}z(\Q12\$34$$\x34\E5$$),substitute_extended,substitute_literal
4600    >>abcd<<
4601
4602/abcd/g,replace=\$1$2\,substitute_literal
4603    XabcdYabcdZ
4604
4605/a(bc)(DE)/replace=a\u$1\U$1\E$1\l$2\L$2\Eab\Uab\LYZ\EDone,substitute_extended
4606    abcDE
4607
4608/abcd/replace=xy\kz,substitute_extended
4609    abcd
4610
4611/a(?:(b)|(c))/substitute_extended,replace=X${1:+1:-1}X${2:+2:-2}
4612    ab
4613    ac
4614    ab\=replace=${1:+$1\:$1:$2}
4615    ac\=replace=${1:+$1\:$1:$2}
4616    >>ac<<\=replace=${1:+$1\:$1:$2},substitute_literal
4617
4618/a(?:(b)|(c))/substitute_extended,replace=X${1:-1:-1}X${2:-2:-2}
4619    ab
4620    ac
4621
4622/(a)/substitute_extended,replace=>${1:+\Q$1:{}$$\E+\U$1}<
4623    a
4624
4625/X(b)Y/substitute_extended
4626    XbY\=replace=x${1:+$1\U$1}y
4627    XbY\=replace=\Ux${1:+$1$1}y
4628
4629/a/substitute_extended,replace=${*MARK:+a:b}
4630    a
4631
4632/(abcd)/replace=${1:+xy\kz},substitute_extended
4633    abcd
4634
4635/(abcd)/
4636    abcd\=replace=${1:+xy\kz},substitute_extended
4637
4638/abcd/substitute_extended,replace=>$1<
4639    abcd
4640
4641/abcd/substitute_extended,replace=>xxx${xyz}<<<
4642    abcd
4643
4644/(?J)(?:(?<A>a)|(?<A>b))/replace=<$A>
4645    [a]
4646    [b]
4647\= Expect error
4648    (a)\=ovector=1
4649
4650/(a)|(b)/replace=<$1>
4651\= Expect error
4652    b
4653
4654/(aa)(BB)/substitute_extended,replace=\U$1\L$2\E$1..\U$1\l$2$1
4655    aaBB
4656
4657/abcd/replace=wxyz,substitute_matched
4658    abcd
4659    pqrs
4660
4661/abcd/g
4662    >abcd1234abcd5678<\=replace=wxyz,substitute_matched
4663
4664/^(o(\1{72}{\"{\\{00000059079}\d*){74}}){19}/I
4665
4666/((p(?'K/
4667
4668/((p(?'K/no_auto_capture
4669
4670/abc/replace=A$3123456789Z
4671    abc
4672
4673/(?<!a{65535}a{5})x/I
4674
4675/(?<!a{65535})x/I
4676
4677/(?=a\K)/replace=z,allow_lookaround_bsk
4678    BaCaD
4679
4680/(?<=\K.)/g,replace=-,allow_lookaround_bsk
4681    ab
4682
4683/(?'abcdefghijklmnopqrstuvwxyzABCDEFGabcdefghijklmnopqrstuvwxyzABCDEabcdefghijklmnopqrstuvwxyzABCDEabcdefghijklmnopqrstuvwxyzABCDEFGH'toolong)/
4684
4685/(?'abcdefghijklmnopqrstuvwxyzABCDEFGabcdefghijklmnopqrstuvwxyzABCDEabcdefghijklmnopqrstuvwxyzABCDEabcdefghijklmnopqrstuvwxyzABCDEFG'justright)/
4686
4687# These two use zero-termination
4688/abcd/max_pattern_length=3
4689
4690/abc/max_pattern_length=3
4691
4692# These two, being hex, pass the length
4693/abcdefab/hex,max_pattern_length=3
4694
4695/abcdef/hex,max_pattern_length=3
4696
4697# Test compiled length limit
4698/(abcdefg){10}/max_pattern_compiled_length=100
4699
4700# These patterns used to take a long time to compile
4701
4702"(.*)
4703((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4704((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4705((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))"xI
4706
4707"(?<=a()
4708((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4709((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4710((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4711a)"xI
4712
4713"(?|()|())(.*)
4714((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4715((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4716((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))"xI
4717
4718"(?|()|())(?<=a()
4719((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4720((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4721((?-2)(?-2))((?-2)(?-2))((?-2)(?-2))
4722a)"xI
4723
4724# Test the use of malloc for caching group information when there are more
4725# groups than fit into the on-stack workspace.
4726
4727/\[()]{1024}/I,expand
4728
4729# Test minlength capped at 65535
4730
4731/(A{65000})\1{65000}/I
4732
4733# Test group scans when numbers are not unique
4734
4735/(?|()+|(a)+)/BI
4736
4737/(?|(a)+|()+)/BI
4738
4739/(?|()|(a))/BI
4740
4741/(?|(a)|())/BI
4742
4743# Test CRLF handling in empty string substitutions
4744
4745/^$/gm,newline=anycrlf,replace=-
4746    X\r\n\r\nY
4747
4748/^$/gm,newline=crlf,replace=-
4749    X\r\n\r\nY
4750
4751/^$/gm,newline=any,replace=-
4752    X\r\n\r\nY
4753
4754"(*ANYCRLF)(?m)^(.*[^0-9\r\n].*|)$"g,replace=NaN
4755    15\r\nfoo\r\n20\r\nbar\r\nbaz\r\n\r\n20
4756
4757/a[[:punct:]b]/bincode
4758
4759/a[b[:punct:]]/bincode
4760
4761/L(?#(|++<!(2)?/B
4762
4763/L(?#(|++<!(2)?/B,no_auto_possess
4764
4765/L(?#(|++<!(2)?/B,auto_callout
4766
4767/L(?#(|++<!(2)?/B,no_auto_possess,auto_callout
4768
4769/(A*)\E+/B,auto_callout
4770
4771/()\Q\E*]/B,auto_callout
4772    a[bc]d
4773
4774/\x8a+f|;T?(*:;.'?`(\xeap ){![^()!y*''C*(?';]{1;(\x08)/B,alt_verbnames,dupnames,extended
4775
4776# Tests for NULL characters in comments and verb "names" and callouts
4777
4778# /A#B\x00C\x0aZ/
4779/41 23 42 00 43 0a 5a/Bx,hex
4780
4781# /A+#B\x00C\x0a+/
4782/41 2b 23 42 00 43 0a 2b/Bx,hex
4783
4784# /A(*:B\x00W#X\00Y\x0aC)Z/
4785/41 28 2a 3a 42 00 57 23 58 00 59 0a 43 29 5a/Bx,hex,alt_verbnames
4786
4787# /A(*:B\x00W#X\00Y\x0aC)Z/
4788/41 28 2a 3a 42 00 57 23 58 00 59 0a 43 29 5a/Bx,hex
4789
4790# /A(?C{X\x00Y})B/
4791/41 28 3f 43 7b 58 00 59 7d 29 42/B,hex
4792
4793# /A(?#X\x00Y)B/
4794/41 28 3f 23 7b 00 7d 29 42/B,hex
4795
4796# Tests for leading comment in extended patterns
4797
4798/ (?-x):?/extended
4799
4800/(?-x):?/extended
4801
4802/0b 28 3f 2d 78 29 3a/hex,extended
4803
4804/#comment
4805(?-x):?/extended
4806
4807/(8(*:6^\x09x\xa6l\)6!|\xd0:[^:|)\x09d\Z\d{85*m(?'(?<1!)*\W[*\xff]!!h\w]*\xbe;/alt_bsux,alt_verbnames,allow_empty_class,dollar_endonly,extended,multiline,never_utf,no_dotstar_anchor,no_start_optimize
4808
4809/a|(b)c/replace=>$1<,substitute_unset_empty
4810    cat
4811    xbcom
4812
4813/a|(b)c/
4814    cat\=replace=>$1<
4815    cat\=replace=>$1<,substitute_unset_empty
4816    xbcom\=replace=>$1<,substitute_unset_empty
4817
4818/a|(b)c/substitute_extended
4819    cat\=replace=>${2:-xx}<
4820    cat\=replace=>${2:-xx}<,substitute_unknown_unset
4821    cat\=replace=>${X:-xx}<,substitute_unknown_unset
4822
4823/a|(?'X'b)c/replace=>$X<,substitute_unset_empty
4824    cat
4825    xbcom
4826
4827/a|(?'X'b)c/replace=>$Y<,substitute_unset_empty
4828    cat
4829    cat\=substitute_unknown_unset
4830    cat\=substitute_unknown_unset,-substitute_unset_empty
4831
4832/a|(b)c/replace=>$2<,substitute_unset_empty
4833    cat
4834    cat\=substitute_unknown_unset
4835    cat\=substitute_unknown_unset,-substitute_unset_empty
4836
4837/()()()/use_offset_limit
4838    \=ovector=11000000000
4839    \=callout_fail=11000000000
4840    \=callout_fail=1:11000000000
4841    \=callout_data=11000000000
4842    \=callout_data=-11000000000
4843    \=offset_limit=1100000000000000000000
4844    \=copy=11000000000
4845
4846/(*MARK:A\x00b)/mark
4847    abc
4848
4849/(*MARK:A\x00b)/mark,alt_verbnames
4850    abc
4851
4852/"(*MARK:A" 00 "b)"/mark,hex
4853    abc
4854
4855/"(*MARK:A" 00 "b)"/mark,hex,alt_verbnames
4856    abc
4857
4858/efg/hex
4859
4860/eff/hex
4861
4862/effg/hex
4863
4864/(?J)(?'a'))(?'a')/
4865
4866/(?<=((?C)0))/
4867    9010
4868\= Expect no match
4869    abc
4870
4871/aaa/
4872\[abc]{10000000000000000000000000000}
4873\[a]{3}
4874
4875/\[AB]{6000000000000000000000}/expand
4876
4877# Hex uses pattern length, not zero-terminated. This tests for overrunning
4878# the given length of a pattern.
4879
4880/'(*U'/hex
4881
4882/'(*'/hex
4883
4884/'('/hex
4885
4886//hex
4887
4888# These tests are here because Perl never allows a back reference in a
4889# lookbehind. PCRE2 supports some limited cases.
4890
4891/([ab])...(?<=\1)z/
4892    a11az
4893    b11bz
4894\= Expect no match
4895    b11az
4896
4897/(?|([ab]))...(?<=\1)z/
4898
4899/([ab])(\1)...(?<=\2)z/
4900    aa11az
4901
4902/(a\2)(b\1)(?<=\2)/
4903
4904/(?<A>[ab])...(?<=\k'A')z/
4905    a11az
4906    b11bz
4907\= Expect no match
4908    b11az
4909
4910/(?<A>[ab])...(?<=\k'A')(?<A>)z/dupnames
4911
4912# Perl does not support \g+n
4913
4914/((\g+1X)?([ab]))+/
4915    aaXbbXa
4916
4917/ab(?C1)c/auto_callout
4918    abc
4919
4920/'ab(?C1)c'/hex,auto_callout
4921    abc
4922
4923# Perl accepts these, but gives a warning. We can't warn, so give an error.
4924
4925/[a-[:digit:]]+/
4926    a-a9-a
4927
4928/[A-[:digit:]]+/
4929    A-A9-A
4930
4931/[a-\d]+/
4932    a-a9-a
4933
4934/(?<RA>abc)(?(R)xyz)/B
4935
4936/(?<R>abc)(?(R)xyz)/B
4937
4938/(?=.*[A-Z])/I
4939
4940/()(?<=(?0))/
4941
4942/(?<!|!(?<!))/
4943
4944/(?<!|!|!||||||(?<!)||(?<!)!|!||(?<!)!|!(?<!)!|!|!|!||||!!|<!)!|!||||!|/
4945
4946/{2,2{2,2/use_length
4947
4948/.>*?\g'0/use_length
4949
4950/.>*?\g'0/
4951
4952/{�̈́�̈́�{'{22{2{{2{'{22{{22{2{'{22{2{{2{{222{{2{'{22{2{22{2{'{22{2{{2{'{22{2{22{2{'{'{22{2{22{2{'{22{2{{2{'{22{2{22{2{'{222{2Ą̈́�̈́�{'{22{2{{2{'{22{{11{2{'{22{2{{2{{'{22{2{{2{'{22{{22{1{'{22{2{{2{{222{{2{'{22{2{22{2{'{/auto_callout
4953
4954//
4955\=get=i00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
4956\=get=i2345678901234567890123456789012,get=i1245678901234567890123456789012
4957
4958"(?(?C))"
4959
4960/(?(?(?(?(?(?))))))/
4961
4962/(?<=(?1))((?s))/anchored
4963
4964/(*:ab)*/
4965
4966%(*:(:(svvvvvvvvvv:]*[   Z!*;[]*[^[]*!^[+.+{{2,7}'      _\\\\\\\\\\\\\)?.:..    *w////\\\Q\\\\\\\\\\\\\\\T\\\\\+/?/////'+\\\EEE?/////'+/*+/[^K]?]//(w)%never_backslash_c,alt_verbnames,auto_callout
4967
4968/./newline=crlf
4969    \=ph
4970
4971/(\x0e00\000000\xc)/replace=\P,substitute_extended
4972    \x0e00\000000\xc
4973
4974//replace=0
4975    \=offset=7
4976
4977/(?<=\G.)/g,replace=+
4978    abc
4979
4980".+\QX\E+"B,no_auto_possess
4981
4982".+\QX\E+"B,auto_callout,no_auto_possess
4983
4984# This one is here because Perl gives an 'unmatched )' error which goes away
4985# if one of the \) sequences is removed - which is weird. PCRE finds it too
4986# complicated to find a minimum matching length.
4987
4988"()X|((((((((()))))))((((())))))\2())((((((\2\2)))\2)(\22((((\2\2)2))\2)))(2\ZZZ)+:)Z^|91ZiZZnter(ZZ |91Z(ZZ ZZ(\r2Z( or#(\Z2(Z\Z(\2\2)2))\2Z)Z(\22Z((\Z2(Z\Z(\2\2)2))\2Z+:)Z|91Z(ZZ ZZ(\r2Z( or#(\Z2(Z\Z((Z*(\2(Z\':))\0)i|||||||||||||||loZ\2\2)2))\2Z)Z(\22Z((\Z2(Z\Z(\2\2)2))\2Z)))int \)\0nte!rnal errpr\2\\21r(2\ZZZ)+:)Z!|91Z(ZZ ZZ(\r2Z( or#(\Z2(Z\Z(\2\2)2))\2Z)Z(\22Z((\Z2(Z\Z(\2\2)2))\2Z)))int \)\0(2\ZZZ)+:)Z^|91ZiZZnter(ZZ |91Z(ZZ ZZ(\r2Z( or#(\Z2(Z\Z(\2\2)2))\2Z)Z(\22Z((\Z2(Z\Z(\2\2)2))\2Z)))int \)\0(2\ZZZ)+:)Z^)))int \)\0(2\ZZZ)+:)Z^|91ZiZZnter(ZZernZal ZZ(\r2Z( or#(\Z2(Z\Z(\2\2)2))\2Z)Z(\22Z((\Z2(Z\Z(\2\2)2))\2Z)))int \))\ZZ(\r2Z( or#(\Z2(Z\Z(\2\2)2))\2Z)Z(\22Z((\Z2(Z\Z(\2\2)))\2))))((((((\2\2))))))"I
4989
4990# This checks that new code for handling groups that may match an empty string
4991# works on a very large number of alternatives. This pattern used to provoke a
4992# complaint that it was too complicated.
4993
4994/(?:\[A|B|C|D|E|F|G|H|I|J|]{200}Z)/expand
4995
4996# This one used to compile rubbish instead of a compile error, and then
4997# behave unpredictably at match time.
4998
4999/.+(?(?C'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'))?!XXXX.=X/
5000    .+(?(?C'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'))?!XXXX.=X
5001
5002/[:[:alnum:]-[[a:lnum:]+/
5003
5004/((?(?C'')\QX\E(?!((?(?C'')(?!X=X));=)r*X=X));=)/
5005
5006/((?(?C'')\Q\E(?!((?(?C'')(?!X=X));=)r*X=X));=)/
5007
5008/abcd/auto_callout
5009    abcd\=callout_error=255:2
5010
5011/()(\g+65534)/
5012
5013/()(\g+65533)/
5014
5015/�\x00\x00\x00�(\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\2*\x00k\d+\x00‎\x00\x00\x00\x00\x00\2*\x00\x00\1*.){36}int^\x00\x00��\x00�(\1{50779}?)J\w2/I
5016
5017/(a)(b)\2\1\1\1\1/I
5018
5019/(?<a>a)(?<b>b)\g{b}\g{a}\g{a}\g{a}\g{a}(?<a>xx)(?<b>zz)/I,dupnames
5020
5021//
5022    \=ovector=7777777777
5023
5024# This is here because Perl matches, even though a COMMIT is encountered
5025# outside of the recursion.
5026
5027/(?1)(A(*COMMIT)|B)D/
5028    BAXBAD
5029
5030"(?1){2}(a)"B
5031
5032"(?1){2,4}(a)"B
5033
5034# This test differs from Perl for the first subject. Perl ends up with
5035# $1 set to 'B'; PCRE2 has it unset (which I think is right).
5036
5037/^(?:
5038(?:A| (?:B|B(*ACCEPT)) (?<=(.)) D)
5039(Z)
5040)+$/x
5041    AZB
5042    AZBDZ
5043
5044# The first of these, when run by Perl, gives the mark 'aa', which is wrong.
5045
5046'(?>a(*:aa))b|ac' mark
5047    ac
5048
5049'(?:a(*:aa))b|ac' mark
5050    ac
5051
5052/(R?){65}/
5053    (R?){65}
5054
5055/\[(a)]{60}/expand
5056    aaaa
5057
5058/(?<!\1((?U)1((?U))))(*F)/never_backslash_c,alt_bsux,anchored,extended
5059
5060/\g{3/
5061
5062/(a(?C1)(b)(c)d)+/
5063  abcdabcd\=callout_capture
5064
5065# Perl matches this one, but PCRE does not because (*ACCEPT) clears out any
5066# pending backtracks in the recursion.
5067
5068/^ (?(DEFINE) (..(*ACCEPT)|...) ) (?1)$/x
5069\= Expect no match
5070    abc
5071
5072# Perl gives no match for this one
5073
5074/(a(*MARK:m)(*ACCEPT)){0}(?1)/mark
5075    abc
5076
5077/abc/endanchored
5078    xyzabc
5079\= Expect no match
5080    xyzabcdef
5081\= Expect error
5082    xyzabc\=ph
5083
5084/abc/
5085    xyzabc\=endanchored
5086\= Expect no match
5087    xyzabcdef\=endanchored
5088\= Expect error
5089    xyzabc\=ps,endanchored
5090
5091/abc(*ACCEPT)d/endanchored
5092    xyzabc
5093\= Expect no match
5094    xyzabcdef
5095
5096/abc|bcd/endanchored
5097    xyzabcd
5098\= Expect no match
5099    xyzabcdef
5100
5101/a(*ACCEPT)x|aa/endanchored
5102    aaa
5103
5104# Check auto-anchoring when there is a group that is never obeyed at
5105# the start of a branch.
5106
5107/(?(DEFINE)(a))^bc/I
5108
5109/(a){0}.*bc/sI
5110
5111# This should be anchored, as the condition is always false and there is
5112# no alternative branch.
5113
5114/(?(VERSION>=999)yes)^bc/I
5115
5116# This should not be anchored.
5117
5118/(?(VERSION>=999)yes|no)^bc/I
5119
5120/(*LIMIT_HEAP=0)xxx/I
5121
5122/\d{0,3}(*:abc)(?C1)xxx/callout_info
5123
5124# ----------------------------------------------------------------------
5125
5126# These are a whole pile of tests that touch lines of code that are not
5127# used by any other tests (at least when these were created).
5128
5129/^a+?x/i,no_start_optimize,no_auto_possess
5130\= Expect no match
5131    aaa
5132
5133/^[^a]{3,}?x/i,no_start_optimize,no_auto_possess
5134\= Expect no match
5135    bbb
5136    cc
5137
5138/^X\S/no_start_optimize,no_auto_possess
5139\= Expect no match
5140    X
5141
5142/^X\W/no_start_optimize,no_auto_possess
5143\= Expect no match
5144    X
5145
5146/^X\H/no_start_optimize,no_auto_possess
5147\= Expect no match
5148    X
5149
5150/^X\h/no_start_optimize,no_auto_possess
5151\= Expect no match
5152    X
5153
5154/^X\V/no_start_optimize,no_auto_possess
5155\= Expect no match
5156    X
5157
5158/^X\v/no_start_optimize,no_auto_possess
5159\= Expect no match
5160    X
5161
5162/^X\h/no_start_optimize,no_auto_possess
5163\= Expect no match
5164    XY
5165
5166/^X\V/no_start_optimize,no_auto_possess
5167\= Expect no match
5168    X\n
5169
5170/^X\v/no_start_optimize,no_auto_possess
5171\= Expect no match
5172    XX
5173
5174/^X.+?/s,no_start_optimize,no_auto_possess
5175\= Expect no match
5176    X
5177
5178/^X\R+?/no_start_optimize,no_auto_possess
5179\= Expect no match
5180    XX
5181
5182/^X\H+?/no_start_optimize,no_auto_possess
5183\= Expect no match
5184    X
5185
5186/^X\h+?/no_start_optimize,no_auto_possess
5187\= Expect no match
5188    X
5189
5190/^X\V+?/no_start_optimize,no_auto_possess
5191\= Expect no match
5192    X
5193    X\n
5194
5195/^X\D+?/no_start_optimize,no_auto_possess
5196\= Expect no match
5197    X
5198    X9
5199
5200/^X\S+?/no_start_optimize,no_auto_possess
5201\= Expect no match
5202    X
5203    X\n
5204
5205/^X\W+?/no_start_optimize,no_auto_possess
5206\= Expect no match
5207    X
5208    XX
5209
5210/^X.+?Z/no_start_optimize,no_auto_possess
5211\= Expect no match
5212    XY\n
5213
5214/(*CRLF)^X.+?Z/no_start_optimize,no_auto_possess
5215\= Expect no match
5216    XY\r\=ps
5217
5218/^X\R+?Z/no_start_optimize,no_auto_possess
5219\= Expect no match
5220    X\nX
5221    X\n\r\n
5222    X\n\rY
5223    X\n\nY
5224    X\n\x{0c}Y
5225
5226/(*BSR_ANYCRLF)^X\R+?Z/no_start_optimize,no_auto_possess
5227\= Expect no match
5228    X\nX
5229    X\n\r\n
5230    X\n\rY
5231    X\n\nY
5232    X\n\x{0c}Y
5233
5234/^X\H+?Z/no_start_optimize,no_auto_possess
5235\= Expect no match
5236    XY\t
5237    XYY
5238
5239/^X\h+?Z/no_start_optimize,no_auto_possess
5240\= Expect no match
5241    X\t\t
5242    X\tY
5243
5244/^X\V+?Z/no_start_optimize,no_auto_possess
5245\= Expect no match
5246    XY\n
5247    XYY
5248
5249/^X\v+?Z/no_start_optimize,no_auto_possess
5250\= Expect no match
5251    X\n\n
5252    X\nY
5253
5254/^X\D+?Z/no_start_optimize,no_auto_possess
5255\= Expect no match
5256    XY9
5257    XYY
5258
5259/^X\d+?Z/no_start_optimize,no_auto_possess
5260\= Expect no match
5261    X99
5262    X9Y
5263
5264/^X\S+?Z/no_start_optimize,no_auto_possess
5265\= Expect no match
5266    XY\n
5267    XYY
5268
5269/^X\s+?Z/no_start_optimize,no_auto_possess
5270\= Expect no match
5271    X\n\n
5272    X\nY
5273
5274/^X\W+?Z/no_start_optimize,no_auto_possess
5275\= Expect no match
5276    X.A
5277    X++
5278
5279/^X\w+?Z/no_start_optimize,no_auto_possess
5280\= Expect no match
5281    Xa.
5282    Xaa
5283
5284/^X.{1,3}Z/s,no_start_optimize,no_auto_possess
5285\= Expect no match
5286    Xa.bd
5287
5288/^X\h+Z/no_start_optimize,no_auto_possess
5289\= Expect no match
5290    X\t\t
5291    X\tY
5292
5293/^X\V+Z/no_start_optimize,no_auto_possess
5294\= Expect no match
5295    XY\n
5296    XYY
5297
5298/^(X(*THEN)Y|AB){0}(?1)/
5299    ABX
5300\= Expect no match
5301    XAB
5302
5303/^(?!A(?C1)B)C/
5304    ABC\=callout_error=1,no_jit
5305
5306/^(?!A(?C1)B)C/no_start_optimize
5307    ABC\=callout_error=1
5308
5309/^(?(?!A(?C1)B)C)/
5310    ABC\=callout_error=1
5311
5312# ----------------------------------------------------------------------
5313
5314/[a b c]/BxxI
5315
5316/[a b c]/BxxxI
5317
5318/[a b c]/B,extended_more
5319
5320/[ a b c ]/B,extended_more
5321
5322/[a b](?xx: [ 12 ] (?-xx:[ 34 ]) )y z/B
5323
5324# Unsetting /x also unsets /xx
5325
5326/[a b](?xx: [ 12 ] (?-x:[ 34 ]) )y z/B
5327
5328/(a)(?-n:(b))(c)/nB
5329
5330# ----------------------------------------------------------------------
5331# These test the dangerous PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL option.
5332
5333/\j\x{z}\o{82}\L\uabcd\u\U\g{\g/B,\bad_escape_is_literal
5334
5335/\N{\c/IB,bad_escape_is_literal
5336
5337/[\j\x{z}\o\gAb\g]/B,bad_escape_is_literal
5338
5339/[Q-\N]/B,bad_escape_is_literal
5340
5341/[\s-_]/bad_escape_is_literal
5342
5343/[_-\s]/bad_escape_is_literal
5344
5345/[\B\R\X]/B
5346
5347/[\B\R\X]/B,bad_escape_is_literal
5348
5349/[A-\BP-\RV-\X]/B
5350
5351/[A-\BP-\RV-\X]/B,bad_escape_is_literal
5352
5353# ----------------------------------------------------------------------
5354
5355/a\b(c/literal
5356    a\\b(c
5357
5358/a\b(c/literal,caseless
5359    a\\b(c
5360    a\\B(c
5361
5362/a\b(c/literal,firstline
5363    XYYa\\b(c
5364\= Expect no match
5365    X\na\\b(c
5366
5367/a\b?c/literal,use_offset_limit
5368    XXXXa\\b?c\=offset_limit=4
5369\= Expect no match
5370    XXXXa\\b?c\=offset_limit=3
5371
5372/a\b(c/literal,anchored,endanchored
5373    a\\b(c
5374\= Expect no match
5375    Xa\\b(c
5376    a\\b(cX
5377    Xa\\b(cX
5378
5379//literal,extended
5380
5381/a\b(c/literal,auto_callout,no_start_optimize
5382    XXXXa\\b(c
5383
5384/a\b(c/literal,auto_callout
5385    XXXXa\\b(c
5386
5387/(*CR)abc/literal
5388    (*CR)abc
5389
5390/cat|dog/I,match_word
5391    the cat sat
5392\= Expect no match
5393    caterpillar
5394    snowcat
5395    syndicate
5396
5397/(cat)|dog/I,match_line,literal
5398    (cat)|dog
5399\= Expect no match
5400    the cat sat
5401    caterpillar
5402    snowcat
5403    syndicate
5404
5405/a whole line/match_line,multiline
5406    Rhubarb \na whole line\n custard
5407\= Expect no match
5408    Not a whole line
5409
5410# Perl gets this wrong, failing to capture 'b' in group 1.
5411
5412/^(b+|a){1,2}?bc/
5413    bbc
5414
5415# And again here, for the "babc" subject string.
5416
5417/^(b*|ba){1,2}?bc/
5418    babc
5419    bbabc
5420    bababc
5421\= Expect no match
5422    bababbc
5423    babababc
5424
5425/[[:digit:]-a]/
5426
5427/[[:digit:]-[:print:]]/
5428
5429/[\d-a]/
5430
5431/[\H-z]/
5432
5433/[\d-[:print:]]/
5434
5435# Perl gets the second of these wrong, giving no match.
5436
5437"(?<=(a))\1?b"I
5438    ab
5439    aaab
5440
5441"(?=(a))\1?b"I
5442    ab
5443    aaab
5444
5445# JIT does not support callout_extra
5446
5447/(*NO_JIT)(a+)b/auto_callout,no_start_optimize,no_auto_possess
5448\= Expect no match
5449    aac\=callout_extra
5450
5451/(*NO_JIT)a+(?C'XXX')b/no_start_optimize,no_auto_possess
5452\= Expect no match
5453    aac\=callout_extra
5454
5455/\n/firstline
5456    xyz\nabc
5457
5458/\nabc/firstline
5459    xyz\nabc
5460
5461/\x{0a}abc/firstline,newline=crlf
5462\= Expect no match
5463    xyz\r\nabc
5464
5465/[abc]/firstline
5466\= Expect no match
5467    \na
5468
5469# These tests are matched in test 1 as they are Perl compatible. Here we are
5470# looking at what does and does not get auto-possessified.
5471
5472/(?(DEFINE)(?<optional_a>a?))^(?&optional_a)a$/B
5473
5474/(?(DEFINE)(?<optional_a>a?)X)^(?&optional_a)a$/B
5475
5476/^(a?)b(?1)a/B
5477
5478/^(a?)+b(?1)a/B
5479
5480/^(a?)++b(?1)a/B
5481
5482/^(a?)+b/B
5483
5484/(?=a+)a(a+)++b/B
5485
5486/(?<=(?=.){4,5}x)/B
5487
5488# Perl behaves differently with these when optimization is turned off
5489
5490/a(*PRUNE:X)bc|qq/mark,no_start_optimize
5491\= Expect no match
5492    axy
5493
5494/a(*THEN:X)bc|qq/mark,no_start_optimize
5495\= Expect no match
5496    axy
5497
5498/(?^x-i)AB/
5499
5500/(?^-i)AB/
5501
5502/(?x-i-i)/
5503
5504/(?(?=^))b/I
5505    abc
5506
5507/(?(?=^)|)b/I
5508    abc
5509
5510/(?(?=^)|^)b/I
5511    bbc
5512\= Expect no match
5513    abc
5514
5515/(?(1)^|^())/I
5516
5517/(?(1)^())b/I
5518
5519/(?(1)^())+b/I,aftertext
5520    abc
5521
5522/(?(1)^()|^)+b/I,aftertext
5523    bbc
5524\= Expect no match
5525    abc
5526
5527/(?(1)^()|^)*b/I,aftertext
5528    bbc
5529    abc
5530    xbc
5531
5532/(?(1)^())+b/I,aftertext
5533    abc
5534
5535/(?(1)^a()|^a)+b/I,aftertext
5536    abc
5537\= Expect no match
5538    bbc
5539
5540/(?(1)^|^(a))+b/I,aftertext
5541    abc
5542\= Expect no match
5543    bbc
5544
5545/(?(1)^a()|^a)*b/I,aftertext
5546    abc
5547    bbc
5548    xbc
5549
5550/a(b)c|xyz/g,allvector,replace=<$0>
5551    abcdefabcpqr\=ovector=4
5552    abxyz\=ovector=4
5553    abcdefxyz\=ovector=4
5554
5555/a(b)c|xyz/allvector
5556    abcdef\=ovector=4
5557    abxyz\=ovector=4
5558
5559/a(b)c|xyz/g,replace=<$0>,substitute_callout
5560    abcdefabcpqr
5561    abxyzpqrabcxyz
5562    12abc34xyz99abc55\=substitute_stop=2
5563    12abc34xyz99abc55\=substitute_skip=1
5564    12abc34xyz99abc55\=substitute_skip=2
5565
5566/a(b)c|xyz/g,replace=<$0>
5567    abcdefabcpqr
5568    abxyzpqrabcxyz
5569    12abc34xyz\=substitute_stop=2
5570    12abc34xyz\=substitute_skip=1
5571
5572/a(b)c|xyz/replace=<$0>
5573    abcdefabcpqr
5574    12abc34xyz\=substitute_skip=1
5575    12abc34xyz\=substitute_stop=1
5576
5577/abc\rdef/
5578    abc\ndef
5579
5580/abc\rdef\x{0d}xyz/escaped_cr_is_lf
5581    abc\ndef\rxyz
5582\= Expect no match
5583    abc\ndef\nxyz
5584
5585/(?(*ACCEPT)xxx)/
5586
5587/(?(*atomic:xx)xxx)/
5588
5589/(?(*script_run:xxx)zzz)/
5590
5591/foobar/
5592    the foobar thing\=copy_matched_subject
5593    the foobar thing\=copy_matched_subject,zero_terminate
5594
5595/foobar/g
5596    the foobar thing foobar again\=copy_matched_subject
5597
5598/(*:XX)^abc/I
5599
5600/(*COMMIT:XX)^abc/I
5601
5602/(*ACCEPT:XX)^abc/I
5603
5604/abc/replace=xyz
5605    abc\=null_context
5606
5607/abc/replace=xyz,substitute_callout
5608    abc
5609\= Expect error message
5610    abc\=null_context
5611
5612/\[()]{65535}()/expand
5613
5614/\[()]{65535}(?<A>)/expand
5615
5616/a(?:(*ACCEPT))??bc/
5617    abc
5618    axy
5619
5620/a(*ACCEPT)??bc/
5621    abc
5622    axy
5623
5624/a(*ACCEPT:XX)??bc/mark
5625    abc
5626    axy
5627
5628/(*:\)?/
5629
5630/(*:\Q \E){5}/alt_verbnames
5631
5632/(?=abc)/I
5633
5634/(?|(X)|(XY))\1abc/I
5635
5636/(?|(a)|(bcde))(c)\2/I
5637
5638/(?|(a)|(bcde))(c)\1/I
5639
5640/(?|(?'A'a)|(?'A'bcde))(?'B'c)\k'B'(?'A')/I,dupnames
5641
5642/(?|(?'A'a)|(?'A'bcde))(?'B'c)\k'A'(?'A')/I,dupnames
5643
5644/((a|)+)+Z/I
5645
5646/((?=a))[abcd]/I
5647
5648/A(?:(*ACCEPT))?B/info
5649
5650/(A(*ACCEPT)??B)C/
5651    ABC
5652    AXY
5653
5654/(?<=(?<=a)b)c.*/I
5655    abc\=ph
5656\= Expect no match
5657    xbc\=ph
5658
5659/(?<=ab)c.*/I
5660    abc\=ph
5661\= Expect no match
5662    xbc\=ph
5663
5664/(?<=a(?<=a|a)c)/I
5665
5666/(?<=a(?<=a|ba)c)/I
5667
5668/(?<=(?<=a)b)(?<!abcd)/I
5669
5670/(?<=(?<=a)b)(?<!abcd)(?<=(?<=a)bcde)/I
5671
5672# Addition overflow
5673/( {32742} {42})(?<!\1{65481})/
5674
5675# Multiplication overflow
5676/(X{65535})(?<=\1{32770})/
5677
5678# ---- Non-atomic assertion tests ----
5679
5680# Expect error: not allowed as a condition
5681/(?(*napla:xx)bc)/
5682
5683/\A(*pla:.*\b(\w++))(?>.*?\b\1\b){3}/
5684    word1 word3 word1 word2 word3 word2 word2 word1 word3 word4
5685
5686/\A(*napla:.*\b(\w++))(?>.*?\b\1\b){3}/
5687    word1 word3 word1 word2 word3 word2 word2 word1 word3 word4
5688
5689/\A(?*.*\b(\w++))(?>.*?\b\1\b){3}/
5690    word1 word3 word1 word2 word3 word2 word2 word1 word3 word4
5691
5692/(*plb:(.)..|(.)...)(\1|\2)/
5693    abcdb\=offset=4
5694    abcda\=offset=4
5695
5696/(*naplb:(.)..|(.)...)(\1|\2)/
5697    abcdb\=offset=4
5698    abcda\=offset=4
5699
5700/(?<*(.)..|(.)...)(\1|\2)/
5701    abcdb\=offset=4
5702    abcda\=offset=4
5703
5704/(*non_atomic_positive_lookahead:ab)/B
5705
5706/(*non_atomic_positive_lookbehind:ab)/B
5707
5708/(*pla:ab+)/B
5709
5710/(*napla:ab+)/B
5711
5712/(*napla:)+/
5713
5714/(*naplb:)+/
5715
5716/(*napla:^x|^y)/I
5717
5718/(*napla:abc|abd)/I
5719
5720/(*napla:a|(.)(*ACCEPT)zz)\1../
5721    abcd
5722
5723/(*napla:a(*ACCEPT)zz|(.))\1../
5724    abcd
5725
5726/(*napla:a|(*COMMIT)(.))\1\1/
5727    aabc
5728\= Expect no match
5729    abbc
5730
5731/(*napla:a|(.))\1\1/
5732    aabc
5733    abbc
5734
5735/(*naplb:ab?c|PQ).../g
5736    abcdefgacxyzPQR123
5737
5738# ----
5739
5740# Expect error (recursion => not fixed length)
5741/(\2)((?=(?<=\1)))/
5742
5743/c*+(?<=[bc])/
5744    abc\=ph
5745    ab\=ph
5746    abc\=ps
5747    ab\=ps
5748
5749/c++(?<=[bc])/
5750    abc\=ph
5751    ab\=ph
5752
5753/(?<=(?=.(?<=x)))/
5754    abx
5755    ab\=ph
5756    bxyz
5757    xyz
5758
5759/\z/
5760   abc\=ph
5761   abc\=ps
5762
5763/\Z/
5764   abc\=ph
5765   abc\=ps
5766   abc\n\=ph
5767   abc\n\=ps
5768
5769/(?![ab]).*/
5770    ab\=ph
5771
5772/c*+/
5773    ab\=ph,offset=2
5774
5775/\A\s*(a|(?:[^`]{28500}){4})/I
5776    a
5777
5778/\A\s*((?:[^`]{28500}){4})/I
5779
5780/\A\s*((?:[^`]{28500}){4}|a)/I
5781    a
5782
5783/(?<A>a)(?(<A>)b)((?<=b).*)/B
5784
5785/(?(1)b)((?<=b).*)/B
5786
5787/(?(R1)b)((?<=b).*)/B
5788
5789/(?(DEFINE)b)((?<=b).*)/B
5790
5791/(?(VERSION=10.3)b)((?<=b).*)/B
5792
5793/[aA]b[cC]/IB
5794
5795/[cc]abcd/I
5796
5797/[Cc]abcd/I
5798
5799/[c]abcd/I
5800
5801/(?:c|C)abcd/I
5802
5803/(a)?a/I
5804    manm
5805
5806/^(?|(\*)(*napla:\S*_(\2?+.+))|(\w)(?=\S*_(\2?+\1)))+_\2$/
5807    *abc_12345abc
5808
5809/^(?|(\*)(*napla:\S*_(\3?+.+))|(\w)(?=\S*_((\2?+\1))))+_\2$/
5810    *abc_12345abc
5811
5812/^((\1+)(?C)|\d)+133X$/
5813    111133X\=callout_capture
5814
5815/abc/replace=xyz,substitute_replacement_only
5816    123abc456
5817
5818/a(?<ONE>b)c(?<TWO>d)e/g,replace=X$ONE+${TWO}Z,substitute_replacement_only
5819    "abcde-abcde-"
5820
5821/a(b)c|xyz/g,replace=<$0>,substitute_callout,substitute_replacement_only
5822    abcdefabcpqr
5823    abxyzpqrabcxyz
5824    12abc34xyz99abc55\=substitute_stop=2
5825    12abc34xyz99abc55\=substitute_skip=1
5826    12abc34xyz99abc55\=substitute_skip=2
5827
5828/a(..)d/replace=>$1<,substitute_matched
5829    xyzabcdxyzabcdxyz
5830    xyzabcdxyzabcdxyz\=ovector=2
5831\= Expect error
5832    xyzabcdxyzabcdxyz\=ovector=1
5833
5834/a(..)d/g,replace=>$1<,substitute_matched
5835    xyzabcdxyzabcdxyz
5836    xyzabcdxyzabcdxyz\=ovector=2
5837\= Expect error
5838    xyzabcdxyzabcdxyz\=ovector=1
5839    xyzabcdxyzabcdxyz\=ovector=1,substitute_unset_empty
5840
5841/55|a(..)d/g,replace=>$1<,substitute_matched
5842    xyz55abcdxyzabcdxyz\=ovector=2,substitute_unset_empty
5843\= Expect error
5844    xyz55abcdxyzabcdxyz\=ovector=2
5845
5846/55|a(..)d/replace=>$1<,substitute_matched
5847    xyz55abcdxyzabcdxyz\=ovector=2,substitute_unset_empty
5848
5849/55|a(..)d/replace=>$1<
5850    xyz55abcdxyzabcdxyz\=ovector=2,substitute_unset_empty
5851
5852/55|a(..)d/g,replace=>$1<
5853    xyz55abcdxyzabcdxyz\=ovector=2,substitute_unset_empty
5854
5855/abc/replace=,caseless
5856    XabcY
5857    XABCY
5858
5859/abc/replace=[4],caseless
5860    XabcY
5861    XABCY
5862
5863/abc/replace=*,caseless
5864    XabcY
5865    XABCY
5866    XabcY\=replace=
5867
5868# Expect non-fixed-length error
5869
5870"(?<=X(?(DEFINE)(.*))(?1))."
5871
5872/\sxxx\s/tables=1
5873\= Expect no match
5874    AB\x{85}xxx\x{a0}XYZ
5875
5876/\sxxx\s/tables=2
5877    AB\x{85}xxx\x{a0}XYZ
5878
5879/^\w+/tables=2
5880    École
5881
5882/^\w+/tables=3
5883    École
5884
5885#loadtables ./testbtables
5886
5887/^\w+/tables=3
5888    École
5889
5890/"(*MARK:>" 00 "<).."/hex,mark,no_start_optimize
5891    AB
5892    A\=ph
5893\= Expect no match
5894    A
5895
5896/"(*MARK:>" 00 "<).(?C1)."/hex,mark,no_start_optimize
5897    AB
5898
5899/(?(VERSION=0.0/
5900
5901# Perl has made \K in lookarounds an error. PCRE2 now rejects as well, unless
5902# explicitly authorized.
5903
5904/(?=a\Kb)ab/
5905
5906/(?=a\Kb)ab/allow_lookaround_bsk
5907    ab
5908
5909/(?!a\Kb)ac/
5910
5911/(?!a\Kb)ac/allow_lookaround_bsk
5912    ac
5913
5914/^abc(?<=b\Kc)d/
5915
5916/^abc(?<=b\Kc)d/allow_lookaround_bsk
5917    abcd
5918
5919/^abc(?<!b\Kq)d/
5920
5921/^abc(?<!b\Kq)d/,allow_lookaround_bsk
5922    abcd
5923
5924# ---------
5925
5926# Tests for zero-length NULL to be treated as an empty string.
5927
5928//
5929    \=null_subject
5930\= Expect error
5931    abc\=null_subject
5932
5933//replace=[20]
5934    abc\=null_replacement
5935    \=null_subject
5936    \=null_replacement
5937
5938/X*/g,replace=xy
5939\= Expect error
5940    >X<\=null_replacement
5941
5942/X+/replace=[20]
5943    >XX<\=null_replacement
5944
5945# ---------
5946
5947/[Aa]{2}/BI
5948    aabcd
5949
5950/A{2}/iBI
5951    aabcd
5952
5953/[Aa]{2,3}/BI
5954    aabcd
5955
5956--
5957    \[X]{-10}
5958
5959# Check imposition of maximum by match_data_create().
5960
5961/abcd/
5962    abcd\=ovector=65536
5963
5964# Use recurse to test \K and Mark in atomic scope.
5965/(?>this line\s*((?R)|)\K)/
5966    this line this line this line
5967
5968/(?>this line\s*((?R)|)(*MARK:A))/
5969    this line this line this line
5970
5971# Check use of NULL pattern with zero length.
5972
5973//null_pattern,use_length
5974    abc
5975
5976//null_pattern
5977
5978/bad null pattern/null_pattern,use_length
5979
5980/bad null pattern/null_pattern
5981
5982# -------- Variable length lookbehinds --------
5983/12345(?<=\d{1,256})X/
5984
5985/(?<=(\d{1,256}))X/max_varlookbehind=256
5986    12345XYZ
5987
5988/12345(?<=a?bc)X/max_varlookbehind=0
5989
5990/12345(?<=abc)X/max_varlookbehind=0
5991
5992/(?<!( {65054}){9,44965})/
5993
5994/(?(?<!|(|a)))/
5995    aaaa\=get=0
5996
5997/(?(?<!|a?))/
5998    aaaa\=get=0
5999
6000# --------
6001
6002/(?<=(()()()()()()()()()()()()()(()()()()(())()()()()(()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(())()()()()(()()()()()()(()()()()()()()()()()()()()()()()()()()()()(())()()()()(()()()()()()()()()()()()()(()()()()()()()()()()()()()(()())))))))))/
6003
6004/(?<!( {65054}){0,44965})/auto_callout
6005
6006/A+{,3}/
6007
6008/(\g{+1}Z|(A))+/
6009    BAAZCD
6010    ZAAAZAZAZAACD
6011
6012# This doesn't work in Perl (though I think it used to)
6013
6014/^(?=.*(?=(([A-Z]).*(?(1)\1)))(?!.+\2)){26}/i
6015    The quick brown fox jumps over the lazy dog.
6016    Jackdaws love my big sphinx of quartz.
6017    Pack my box with five dozen liquor jugs.
6018\= Expect no match
6019    The quick brown fox jumps over the lazy cat.
6020    Hackdaws love my big sphinx of quartz.
6021    Pack my fox with five dozen liquor jugs.
6022
6023# These are different to Perl because of the different capturing in repeating
6024# groups.
6025
6026/((foo)|(bar))*/
6027    foobar
6028
6029/(?:(f)(o)(o)|(b)(a)(r))*/
6030    foobar
6031
6032/((Z)+|A)*/
6033    ZABCDEFG
6034
6035/(?:(?P=same)?(?:(?P<same>a)|(?P<same>b))(?P=same))+/g,dupnames
6036    bbbaaabaabb
6037
6038# --------
6039
6040/
6041/anchored, firstline
6042    \x0a
6043
6044/
6045/anchored,firstline,no_start_optimize
6046    \x0a
6047
6048/
6049/firstline
6050    \x0a
6051    abc\x0adef
6052
6053# This test is currently broken in the interpreter
6054# /|a(?0)/endanchored
6055#    aaaa
6056
6057/A +/extended
6058
6059/(*ACCEPT)+/B,auto_callout
6060
6061/a\z/
6062    a
6063    a\=noteol
6064
6065# This matches a character that only exists once in the subject, sort of like a
6066# hypothetical "(.)(?<!\1.+)(?!.*\1)". That has unlimited variable length
6067# lookbehind, so is invalid. This pattern doesn't work in Perl 5.38.0.
6068
6069/\G(?:(?=(\1.|)(.))){1,13}?(?!.*\2.*\2)\1\K\2/g
6070    aaabcccdeee
6071
6072/|(?0)./endanchored
6073    abcd
6074
6075/|a(?0)/endanchored
6076    aaaa
6077
6078/(?:|(?0).)(?(R)|\z)/
6079    abcd
6080
6081/a?(?=b(*COMMIT)c|)d/I
6082    bd
6083
6084/(?=b(*COMMIT)c|)d/I
6085    bd
6086
6087/a?(?=b(*COMMIT)c|)d/I,no_start_optimize
6088    bd
6089
6090/(?=b(*COMMIT)c|)d/I,no_start_optimize
6091    bd
6092
6093/a?(?=bc|)d/I,auto_callout
6094    bd
6095
6096/a?(?=bc|)\bd/I
6097    bd
6098
6099/(?0)/
6100    abc\=disable_recurseloop_check,match_limit=100
6101
6102/(a(?1)z||(?1)++)$/
6103    abcd\=disable_recurseloop_check
6104
6105/(((?<=123?456456|ABC)))(?<=\2)../
6106    ABCDEFG
6107    12345645678910
6108
6109# This test is crashing Perl 5.38.2.
6110
6111/[^\S\W]{6}/
6112    .abc def..
6113
6114# End of testinput2
6115