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