1# This set of tests is for features that are compatible with all versions of
2# Perl >= 5.10, in non-UTF mode. It should run clean for the 8-bit, 16-bit, and
3# 32-bit PCRE libraries, and also using the perltest.sh script.
4
5# WARNING: Use only / as the pattern delimiter. Although pcre2test supports
6# a number of delimiters, all those other than / give problems with the
7# perltest.sh script.
8
9#forbid_utf
10#newline_default lf any anycrlf
11#perltest
12
13/the quick brown fox/
14    the quick brown fox
15 0: the quick brown fox
16    What do you know about the quick brown fox?
17 0: the quick brown fox
18\= Expect no match
19    The quick brown FOX
20No match
21    What do you know about THE QUICK BROWN FOX?
22No match
23
24/The quick brown fox/i
25    the quick brown fox
26 0: the quick brown fox
27    The quick brown FOX
28 0: The quick brown FOX
29    What do you know about the quick brown fox?
30 0: the quick brown fox
31    What do you know about THE QUICK BROWN FOX?
32 0: THE QUICK BROWN FOX
33
34/abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
35    abcd\t\n\r\f\a\e9;\$\\?caxyz
36 0: abcd\x09\x0a\x0d\x0c\x07\x1b9;$\?caxyz
37
38/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
39    abxyzpqrrrabbxyyyypqAzz
40 0: abxyzpqrrrabbxyyyypqAzz
41    abxyzpqrrrabbxyyyypqAzz
42 0: abxyzpqrrrabbxyyyypqAzz
43    aabxyzpqrrrabbxyyyypqAzz
44 0: aabxyzpqrrrabbxyyyypqAzz
45    aaabxyzpqrrrabbxyyyypqAzz
46 0: aaabxyzpqrrrabbxyyyypqAzz
47    aaaabxyzpqrrrabbxyyyypqAzz
48 0: aaaabxyzpqrrrabbxyyyypqAzz
49    abcxyzpqrrrabbxyyyypqAzz
50 0: abcxyzpqrrrabbxyyyypqAzz
51    aabcxyzpqrrrabbxyyyypqAzz
52 0: aabcxyzpqrrrabbxyyyypqAzz
53    aaabcxyzpqrrrabbxyyyypAzz
54 0: aaabcxyzpqrrrabbxyyyypAzz
55    aaabcxyzpqrrrabbxyyyypqAzz
56 0: aaabcxyzpqrrrabbxyyyypqAzz
57    aaabcxyzpqrrrabbxyyyypqqAzz
58 0: aaabcxyzpqrrrabbxyyyypqqAzz
59    aaabcxyzpqrrrabbxyyyypqqqAzz
60 0: aaabcxyzpqrrrabbxyyyypqqqAzz
61    aaabcxyzpqrrrabbxyyyypqqqqAzz
62 0: aaabcxyzpqrrrabbxyyyypqqqqAzz
63    aaabcxyzpqrrrabbxyyyypqqqqqAzz
64 0: aaabcxyzpqrrrabbxyyyypqqqqqAzz
65    aaabcxyzpqrrrabbxyyyypqqqqqqAzz
66 0: aaabcxyzpqrrrabbxyyyypqqqqqqAzz
67    aaaabcxyzpqrrrabbxyyyypqAzz
68 0: aaaabcxyzpqrrrabbxyyyypqAzz
69    abxyzzpqrrrabbxyyyypqAzz
70 0: abxyzzpqrrrabbxyyyypqAzz
71    aabxyzzzpqrrrabbxyyyypqAzz
72 0: aabxyzzzpqrrrabbxyyyypqAzz
73    aaabxyzzzzpqrrrabbxyyyypqAzz
74 0: aaabxyzzzzpqrrrabbxyyyypqAzz
75    aaaabxyzzzzpqrrrabbxyyyypqAzz
76 0: aaaabxyzzzzpqrrrabbxyyyypqAzz
77    abcxyzzpqrrrabbxyyyypqAzz
78 0: abcxyzzpqrrrabbxyyyypqAzz
79    aabcxyzzzpqrrrabbxyyyypqAzz
80 0: aabcxyzzzpqrrrabbxyyyypqAzz
81    aaabcxyzzzzpqrrrabbxyyyypqAzz
82 0: aaabcxyzzzzpqrrrabbxyyyypqAzz
83    aaaabcxyzzzzpqrrrabbxyyyypqAzz
84 0: aaaabcxyzzzzpqrrrabbxyyyypqAzz
85    aaaabcxyzzzzpqrrrabbbxyyyypqAzz
86 0: aaaabcxyzzzzpqrrrabbbxyyyypqAzz
87    aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
88 0: aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
89    aaabcxyzpqrrrabbxyyyypABzz
90 0: aaabcxyzpqrrrabbxyyyypABzz
91    aaabcxyzpqrrrabbxyyyypABBzz
92 0: aaabcxyzpqrrrabbxyyyypABBzz
93    >>>aaabxyzpqrrrabbxyyyypqAzz
94 0: aaabxyzpqrrrabbxyyyypqAzz
95    >aaaabxyzpqrrrabbxyyyypqAzz
96 0: aaaabxyzpqrrrabbxyyyypqAzz
97    >>>>abcxyzpqrrrabbxyyyypqAzz
98 0: abcxyzpqrrrabbxyyyypqAzz
99\= Expect no match
100    abxyzpqrrabbxyyyypqAzz
101No match
102    abxyzpqrrrrabbxyyyypqAzz
103No match
104    abxyzpqrrrabxyyyypqAzz
105No match
106    aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
107No match
108    aaaabcxyzzzzpqrrrabbbxyyypqAzz
109No match
110    aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
111No match
112
113/^(abc){1,2}zz/
114    abczz
115 0: abczz
116 1: abc
117    abcabczz
118 0: abcabczz
119 1: abc
120\= Expect no match
121    zz
122No match
123    abcabcabczz
124No match
125    >>abczz
126No match
127
128/^(b+?|a){1,2}?c/
129    bc
130 0: bc
131 1: b
132    bbc
133 0: bbc
134 1: b
135    bbbc
136 0: bbbc
137 1: bb
138    bac
139 0: bac
140 1: a
141    bbac
142 0: bbac
143 1: a
144    aac
145 0: aac
146 1: a
147    abbbbbbbbbbbc
148 0: abbbbbbbbbbbc
149 1: bbbbbbbbbbb
150    bbbbbbbbbbbac
151 0: bbbbbbbbbbbac
152 1: a
153\= Expect no match
154    aaac
155No match
156    abbbbbbbbbbbac
157No match
158
159/^(b+|a){1,2}c/
160    bc
161 0: bc
162 1: b
163    bbc
164 0: bbc
165 1: bb
166    bbbc
167 0: bbbc
168 1: bbb
169    bac
170 0: bac
171 1: a
172    bbac
173 0: bbac
174 1: a
175    aac
176 0: aac
177 1: a
178    abbbbbbbbbbbc
179 0: abbbbbbbbbbbc
180 1: bbbbbbbbbbb
181    bbbbbbbbbbbac
182 0: bbbbbbbbbbbac
183 1: a
184\= Expect no match
185    aaac
186No match
187    abbbbbbbbbbbac
188No match
189
190/^(ba|b*){1,2}?bc/
191    babc
192 0: babc
193 1: ba
194    bbabc
195 0: bbabc
196 1: ba
197    bababc
198 0: bababc
199 1: ba
200\= Expect no match
201    bababbc
202No match
203    babababc
204No match
205
206/^\ca\cA\c[;\c:/
207    \x01\x01\e;z
208 0: \x01\x01\x1b;z
209
210/^[ab\]cde]/
211    athing
212 0: a
213    bthing
214 0: b
215    ]thing
216 0: ]
217    cthing
218 0: c
219    dthing
220 0: d
221    ething
222 0: e
223\= Expect no match
224    fthing
225No match
226    [thing
227No match
228    \\thing
229No match
230
231/^[]cde]/
232    ]thing
233 0: ]
234    cthing
235 0: c
236    dthing
237 0: d
238    ething
239 0: e
240\= Expect no match
241    athing
242No match
243    fthing
244No match
245
246/^[^ab\]cde]/
247    fthing
248 0: f
249    [thing
250 0: [
251    \\thing
252 0: \
253\= Expect no match
254    athing
255No match
256    bthing
257No match
258    ]thing
259No match
260    cthing
261No match
262    dthing
263No match
264    ething
265No match
266
267/^[^]cde]/
268    athing
269 0: a
270    fthing
271 0: f
272\= Expect no match
273    ]thing
274No match
275    cthing
276No match
277    dthing
278No match
279    ething
280No match
281
282/^\�/
283284 0: \x81
285
286/^�/
287288 0: \xff
289
290/^[0-9]+$/
291    0
292 0: 0
293    1
294 0: 1
295    2
296 0: 2
297    3
298 0: 3
299    4
300 0: 4
301    5
302 0: 5
303    6
304 0: 6
305    7
306 0: 7
307    8
308 0: 8
309    9
310 0: 9
311    10
312 0: 10
313    100
314 0: 100
315\= Expect no match
316    abc
317No match
318
319/^.*nter/
320    enter
321 0: enter
322    inter
323 0: inter
324    uponter
325 0: uponter
326
327/^xxx[0-9]+$/
328    xxx0
329 0: xxx0
330    xxx1234
331 0: xxx1234
332\= Expect no match
333    xxx
334No match
335
336/^.+[0-9][0-9][0-9]$/
337    x123
338 0: x123
339    x1234
340 0: x1234
341    xx123
342 0: xx123
343    123456
344 0: 123456
345\= Expect no match
346    123
347No match
348
349/^.+?[0-9][0-9][0-9]$/
350    x123
351 0: x123
352    x1234
353 0: x1234
354    xx123
355 0: xx123
356    123456
357 0: 123456
358\= Expect no match
359    123
360No match
361
362/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
363    abc!pqr=apquxz.ixr.zzz.ac.uk
364 0: abc!pqr=apquxz.ixr.zzz.ac.uk
365 1: abc
366 2: pqr
367\= Expect no match
368    !pqr=apquxz.ixr.zzz.ac.uk
369No match
370    abc!=apquxz.ixr.zzz.ac.uk
371No match
372    abc!pqr=apquxz:ixr.zzz.ac.uk
373No match
374    abc!pqr=apquxz.ixr.zzz.ac.ukk
375No match
376
377/:/
378    Well, we need a colon: somewhere
379 0: :
380\= Expect no match
381    Fail without a colon
382No match
383
384/([\da-f:]+)$/i
385    0abc
386 0: 0abc
387 1: 0abc
388    abc
389 0: abc
390 1: abc
391    fed
392 0: fed
393 1: fed
394    E
395 0: E
396 1: E
397    ::
398 0: ::
399 1: ::
400    5f03:12C0::932e
401 0: 5f03:12C0::932e
402 1: 5f03:12C0::932e
403    fed def
404 0: def
405 1: def
406    Any old stuff
407 0: ff
408 1: ff
409\= Expect no match
410    0zzz
411No match
412    gzzz
413No match
414    fed\x20
415No match
416    Any old rubbish
417No match
418
419/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
420    .1.2.3
421 0: .1.2.3
422 1: 1
423 2: 2
424 3: 3
425    A.12.123.0
426 0: A.12.123.0
427 1: 12
428 2: 123
429 3: 0
430\= Expect no match
431    .1.2.3333
432No match
433    1.2.3
434No match
435    1234.2.3
436No match
437
438/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
439    1 IN SOA non-sp1 non-sp2(
440 0: 1 IN SOA non-sp1 non-sp2(
441 1: 1
442 2: non-sp1
443 3: non-sp2
444    1    IN    SOA    non-sp1    non-sp2   (
445 0: 1    IN    SOA    non-sp1    non-sp2   (
446 1: 1
447 2: non-sp1
448 3: non-sp2
449\= Expect no match
450    1IN SOA non-sp1 non-sp2(
451No match
452
453/^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
454    a.
455 0: a.
456    Z.
457 0: Z.
458    2.
459 0: 2.
460    ab-c.pq-r.
461 0: ab-c.pq-r.
462 1: .pq-r
463    sxk.zzz.ac.uk.
464 0: sxk.zzz.ac.uk.
465 1: .uk
466    x-.y-.
467 0: x-.y-.
468 1: .y-
469\= Expect no match
470    -abc.peq.
471No match
472
473/^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
474    *.a
475 0: *.a
476    *.b0-a
477 0: *.b0-a
478 1: 0-a
479    *.c3-b.c
480 0: *.c3-b.c
481 1: 3-b
482 2: .c
483    *.c-a.b-c
484 0: *.c-a.b-c
485 1: -a
486 2: .b-c
487 3: -c
488\= Expect no match
489    *.0
490No match
491    *.a-
492No match
493    *.a-b.c-
494No match
495    *.c-a.0-c
496No match
497
498/^(?=ab(de))(abd)(e)/
499    abde
500 0: abde
501 1: de
502 2: abd
503 3: e
504
505/^(?!(ab)de|x)(abd)(f)/
506    abdf
507 0: abdf
508 1: <unset>
509 2: abd
510 3: f
511
512/^(?=(ab(cd)))(ab)/
513    abcd
514 0: ab
515 1: abcd
516 2: cd
517 3: ab
518
519/^[\da-f](\.[\da-f])*$/i
520    a.b.c.d
521 0: a.b.c.d
522 1: .d
523    A.B.C.D
524 0: A.B.C.D
525 1: .D
526    a.b.c.1.2.3.C
527 0: a.b.c.1.2.3.C
528 1: .C
529
530/^\".*\"\s*(;.*)?$/
531    \"1234\"
532 0: "1234"
533    \"abcd\" ;
534 0: "abcd" ;
535 1: ;
536    \"\" ; rhubarb
537 0: "" ; rhubarb
538 1: ; rhubarb
539\= Expect no match
540    \"1234\" : things
541No match
542
543/^$/
544    \
545 0:
546\= Expect no match
547    A non-empty line
548No match
549
550/   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/x
551    ab c
552 0: ab c
553\= Expect no match
554    abc
555No match
556    ab cde
557No match
558
559/(?x)   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/
560    ab c
561 0: ab c
562\= Expect no match
563    abc
564No match
565    ab cde
566No match
567
568/^   a\ b[c ]d       $/x
569    a bcd
570 0: a bcd
571    a b d
572 0: a b d
573\= Expect no match
574    abcd
575No match
576    ab d
577No match
578
579/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
580    abcdefhijklm
581 0: abcdefhijklm
582 1: abc
583 2: bc
584 3: c
585 4: def
586 5: ef
587 6: f
588 7: hij
589 8: ij
590 9: j
59110: klm
59211: lm
59312: m
594
595/^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
596    abcdefhijklm
597 0: abcdefhijklm
598 1: bc
599 2: c
600 3: ef
601 4: f
602 5: ij
603 6: j
604 7: lm
605 8: m
606
607/^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
608    a+ Z0+\x08\n\x1d\x12
609 0: a+ Z0+\x08\x0a\x1d\x12
610
611/^[.^$|()*+?{,}]+/
612    .^\$(*+)|{?,?}
613 0: .^$(*+)|{?,?}
614
615/^a*\w/
616    z
617 0: z
618    az
619 0: az
620    aaaz
621 0: aaaz
622    a
623 0: a
624    aa
625 0: aa
626    aaaa
627 0: aaaa
628    a+
629 0: a
630    aa+
631 0: aa
632
633/^a*?\w/
634    z
635 0: z
636    az
637 0: a
638    aaaz
639 0: a
640    a
641 0: a
642    aa
643 0: a
644    aaaa
645 0: a
646    a+
647 0: a
648    aa+
649 0: a
650
651/^a+\w/
652    az
653 0: az
654    aaaz
655 0: aaaz
656    aa
657 0: aa
658    aaaa
659 0: aaaa
660    aa+
661 0: aa
662
663/^a+?\w/
664    az
665 0: az
666    aaaz
667 0: aa
668    aa
669 0: aa
670    aaaa
671 0: aa
672    aa+
673 0: aa
674
675/^\d{8}\w{2,}/
676    1234567890
677 0: 1234567890
678    12345678ab
679 0: 12345678ab
680    12345678__
681 0: 12345678__
682\= Expect no match
683    1234567
684No match
685
686/^[aeiou\d]{4,5}$/
687    uoie
688 0: uoie
689    1234
690 0: 1234
691    12345
692 0: 12345
693    aaaaa
694 0: aaaaa
695\= Expect no match
696    123456
697No match
698
699/^[aeiou\d]{4,5}?/
700    uoie
701 0: uoie
702    1234
703 0: 1234
704    12345
705 0: 1234
706    aaaaa
707 0: aaaa
708    123456
709 0: 1234
710
711/\A(abc|def)=(\1){2,3}\Z/
712    abc=abcabc
713 0: abc=abcabc
714 1: abc
715 2: abc
716    def=defdefdef
717 0: def=defdefdef
718 1: def
719 2: def
720\= Expect no match
721    abc=defdef
722No match
723
724/^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
725    abcdefghijkcda2
726 0: abcdefghijkcda2
727 1: a
728 2: b
729 3: c
730 4: d
731 5: e
732 6: f
733 7: g
734 8: h
735 9: i
73610: j
73711: k
73812: cd
739    abcdefghijkkkkcda2
740 0: abcdefghijkkkkcda2
741 1: a
742 2: b
743 3: c
744 4: d
745 5: e
746 6: f
747 7: g
748 8: h
749 9: i
75010: j
75111: k
75212: cd
753
754/(cat(a(ract|tonic)|erpillar)) \1()2(3)/
755    cataract cataract23
756 0: cataract cataract23
757 1: cataract
758 2: aract
759 3: ract
760 4:
761 5: 3
762    catatonic catatonic23
763 0: catatonic catatonic23
764 1: catatonic
765 2: atonic
766 3: tonic
767 4:
768 5: 3
769    caterpillar caterpillar23
770 0: caterpillar caterpillar23
771 1: caterpillar
772 2: erpillar
773 3: <unset>
774 4:
775 5: 3
776
777
778/^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]/
779    From abcd  Mon Sep 01 12:33:02 1997
780 0: From abcd  Mon Sep 01 12:33
781 1: abcd
782
783/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
784    From abcd  Mon Sep 01 12:33:02 1997
785 0: From abcd  Mon Sep 01 12:33
786 1: Sep
787    From abcd  Mon Sep  1 12:33:02 1997
788 0: From abcd  Mon Sep  1 12:33
789 1: Sep
790\= Expect no match
791    From abcd  Sep 01 12:33:02 1997
792No match
793
794/^12.34/s
795    12\n34
796 0: 12\x0a34
797    12\r34
798 0: 12\x0d34
799
800/\w+(?=\t)/
801    the quick brown\t fox
802 0: brown
803
804/foo(?!bar)(.*)/
805    foobar is foolish see?
806 0: foolish see?
807 1: lish see?
808
809/(?:(?!foo)...|^.{0,2})bar(.*)/
810    foobar crowbar etc
811 0: rowbar etc
812 1:  etc
813    barrel
814 0: barrel
815 1: rel
816    2barrel
817 0: 2barrel
818 1: rel
819    A barrel
820 0: A barrel
821 1: rel
822
823/^(\D*)(?=\d)(?!123)/
824    abc456
825 0: abc
826 1: abc
827\= Expect no match
828    abc123
829No match
830
831/^1234(?# test newlines
832  inside)/
833    1234
834 0: 1234
835
836/^1234 #comment in extended re
837  /x
838    1234
839 0: 1234
840
841/#rhubarb
842  abcd/x
843    abcd
844 0: abcd
845
846/^abcd#rhubarb/x
847    abcd
848 0: abcd
849
850/^(a)\1{2,3}(.)/
851    aaab
852 0: aaab
853 1: a
854 2: b
855    aaaab
856 0: aaaab
857 1: a
858 2: b
859    aaaaab
860 0: aaaaa
861 1: a
862 2: a
863    aaaaaab
864 0: aaaaa
865 1: a
866 2: a
867
868/(?!^)abc/
869    the abc
870 0: abc
871\= Expect no match
872    abc
873No match
874
875/(?=^)abc/
876    abc
877 0: abc
878\= Expect no match
879    the abc
880No match
881
882/^[ab]{1,3}(ab*|b)/
883    aabbbbb
884 0: aabb
885 1: b
886
887/^[ab]{1,3}?(ab*|b)/
888    aabbbbb
889 0: aabbbbb
890 1: abbbbb
891
892/^[ab]{1,3}?(ab*?|b)/
893    aabbbbb
894 0: aa
895 1: a
896
897/^[ab]{1,3}(ab*?|b)/
898    aabbbbb
899 0: aabb
900 1: b
901
902/  (?: [\040\t] |  \(
903(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
904\)  )*                          # optional leading comment
905(?:    (?:
906[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
907(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
908|
909" (?:                      # opening quote...
910[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
911|                     #    or
912\\ [^\x80-\xff]           #   Escaped something (something != CR)
913)* "  # closing quote
914)                    # initial word
915(?:  (?: [\040\t] |  \(
916(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
917\)  )*  \.  (?: [\040\t] |  \(
918(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
919\)  )*   (?:
920[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
921(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
922|
923" (?:                      # opening quote...
924[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
925|                     #    or
926\\ [^\x80-\xff]           #   Escaped something (something != CR)
927)* "  # closing quote
928)  )* # further okay, if led by a period
929(?: [\040\t] |  \(
930(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
931\)  )*  @  (?: [\040\t] |  \(
932(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
933\)  )*    (?:
934[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
935(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
936|   \[                         # [
937(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
938\]                        #           ]
939)                           # initial subdomain
940(?:                                  #
941(?: [\040\t] |  \(
942(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
943\)  )*  \.                        # if led by a period...
944(?: [\040\t] |  \(
945(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
946\)  )*   (?:
947[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
948(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
949|   \[                         # [
950(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
951\]                        #           ]
952)                     #   ...further okay
953)*
954# address
955|                     #  or
956(?:
957[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
958(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
959|
960" (?:                      # opening quote...
961[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
962|                     #    or
963\\ [^\x80-\xff]           #   Escaped something (something != CR)
964)* "  # closing quote
965)             # one word, optionally followed by....
966(?:
967[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
968\(
969(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
970\)       |  # comments, or...
971
972" (?:                      # opening quote...
973[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
974|                     #    or
975\\ [^\x80-\xff]           #   Escaped something (something != CR)
976)* "  # closing quote
977# quoted strings
978)*
979<  (?: [\040\t] |  \(
980(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
981\)  )*                     # leading <
982(?:  @  (?: [\040\t] |  \(
983(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
984\)  )*    (?:
985[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
986(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
987|   \[                         # [
988(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
989\]                        #           ]
990)                           # initial subdomain
991(?:                                  #
992(?: [\040\t] |  \(
993(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
994\)  )*  \.                        # if led by a period...
995(?: [\040\t] |  \(
996(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
997\)  )*   (?:
998[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
999(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1000|   \[                         # [
1001(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
1002\]                        #           ]
1003)                     #   ...further okay
1004)*
1005
1006(?:  (?: [\040\t] |  \(
1007(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1008\)  )*  ,  (?: [\040\t] |  \(
1009(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1010\)  )*  @  (?: [\040\t] |  \(
1011(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1012\)  )*    (?:
1013[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1014(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1015|   \[                         # [
1016(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
1017\]                        #           ]
1018)                           # initial subdomain
1019(?:                                  #
1020(?: [\040\t] |  \(
1021(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1022\)  )*  \.                        # if led by a period...
1023(?: [\040\t] |  \(
1024(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1025\)  )*   (?:
1026[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1027(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1028|   \[                         # [
1029(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
1030\]                        #           ]
1031)                     #   ...further okay
1032)*
1033)* # further okay, if led by comma
1034:                                # closing colon
1035(?: [\040\t] |  \(
1036(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1037\)  )*  )? #       optional route
1038(?:
1039[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1040(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1041|
1042" (?:                      # opening quote...
1043[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
1044|                     #    or
1045\\ [^\x80-\xff]           #   Escaped something (something != CR)
1046)* "  # closing quote
1047)                    # initial word
1048(?:  (?: [\040\t] |  \(
1049(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1050\)  )*  \.  (?: [\040\t] |  \(
1051(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1052\)  )*   (?:
1053[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1054(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1055|
1056" (?:                      # opening quote...
1057[^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
1058|                     #    or
1059\\ [^\x80-\xff]           #   Escaped something (something != CR)
1060)* "  # closing quote
1061)  )* # further okay, if led by a period
1062(?: [\040\t] |  \(
1063(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1064\)  )*  @  (?: [\040\t] |  \(
1065(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1066\)  )*    (?:
1067[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1068(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1069|   \[                         # [
1070(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
1071\]                        #           ]
1072)                           # initial subdomain
1073(?:                                  #
1074(?: [\040\t] |  \(
1075(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1076\)  )*  \.                        # if led by a period...
1077(?: [\040\t] |  \(
1078(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1079\)  )*   (?:
1080[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1081(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1082|   \[                         # [
1083(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
1084\]                        #           ]
1085)                     #   ...further okay
1086)*
1087#       address spec
1088(?: [\040\t] |  \(
1089(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1090\)  )*  > #                  trailing >
1091# name and address
1092)  (?: [\040\t] |  \(
1093(?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
1094\)  )*                       # optional trailing comment
1095/x
1096    Alan Other <user\@dom.ain>
1097 0: Alan Other <user@dom.ain>
1098    <user\@dom.ain>
1099 0: user@dom.ain
1100    user\@dom.ain
1101 0: user@dom.ain
1102    \"A. Other\" <user.1234\@dom.ain> (a comment)
1103 0: "A. Other" <user.1234@dom.ain> (a comment)
1104    A. Other <user.1234\@dom.ain> (a comment)
1105 0:  Other <user.1234@dom.ain> (a comment)
1106    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
1107 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
1108    A missing angle <user\@some.where
1109 0: user@some.where
1110\= Expect no match
1111    The quick brown fox
1112No match
1113
1114/[\040\t]*                    # Nab whitespace.
1115(?:
1116\(                              #  (
1117[^\\\x80-\xff\n\015()] *                             #     normal*
1118(?:                                 #       (
1119(?:  \\ [^\x80-\xff]  |
1120\(                            #  (
1121[^\\\x80-\xff\n\015()] *                            #     normal*
1122(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1123\)                           #                       )
1124)    #         special
1125[^\\\x80-\xff\n\015()] *                         #         normal*
1126)*                                  #            )*
1127\)                             #                )
1128[\040\t]* )*    # If comment found, allow more spaces.
1129# optional leading comment
1130(?:
1131(?:
1132[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1133(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1134# Atom
1135|                       #  or
1136"                                     # "
1137[^\\\x80-\xff\n\015"] *                            #   normal
1138(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1139"                                     #        "
1140# Quoted string
1141)
1142[\040\t]*                    # Nab whitespace.
1143(?:
1144\(                              #  (
1145[^\\\x80-\xff\n\015()] *                             #     normal*
1146(?:                                 #       (
1147(?:  \\ [^\x80-\xff]  |
1148\(                            #  (
1149[^\\\x80-\xff\n\015()] *                            #     normal*
1150(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1151\)                           #                       )
1152)    #         special
1153[^\\\x80-\xff\n\015()] *                         #         normal*
1154)*                                  #            )*
1155\)                             #                )
1156[\040\t]* )*    # If comment found, allow more spaces.
1157(?:
1158\.
1159[\040\t]*                    # Nab whitespace.
1160(?:
1161\(                              #  (
1162[^\\\x80-\xff\n\015()] *                             #     normal*
1163(?:                                 #       (
1164(?:  \\ [^\x80-\xff]  |
1165\(                            #  (
1166[^\\\x80-\xff\n\015()] *                            #     normal*
1167(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1168\)                           #                       )
1169)    #         special
1170[^\\\x80-\xff\n\015()] *                         #         normal*
1171)*                                  #            )*
1172\)                             #                )
1173[\040\t]* )*    # If comment found, allow more spaces.
1174(?:
1175[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1176(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1177# Atom
1178|                       #  or
1179"                                     # "
1180[^\\\x80-\xff\n\015"] *                            #   normal
1181(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1182"                                     #        "
1183# Quoted string
1184)
1185[\040\t]*                    # Nab whitespace.
1186(?:
1187\(                              #  (
1188[^\\\x80-\xff\n\015()] *                             #     normal*
1189(?:                                 #       (
1190(?:  \\ [^\x80-\xff]  |
1191\(                            #  (
1192[^\\\x80-\xff\n\015()] *                            #     normal*
1193(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1194\)                           #                       )
1195)    #         special
1196[^\\\x80-\xff\n\015()] *                         #         normal*
1197)*                                  #            )*
1198\)                             #                )
1199[\040\t]* )*    # If comment found, allow more spaces.
1200# additional words
1201)*
1202@
1203[\040\t]*                    # Nab whitespace.
1204(?:
1205\(                              #  (
1206[^\\\x80-\xff\n\015()] *                             #     normal*
1207(?:                                 #       (
1208(?:  \\ [^\x80-\xff]  |
1209\(                            #  (
1210[^\\\x80-\xff\n\015()] *                            #     normal*
1211(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1212\)                           #                       )
1213)    #         special
1214[^\\\x80-\xff\n\015()] *                         #         normal*
1215)*                                  #            )*
1216\)                             #                )
1217[\040\t]* )*    # If comment found, allow more spaces.
1218(?:
1219[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1220(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1221|
1222\[                            # [
1223(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1224\]                           #           ]
1225)
1226[\040\t]*                    # Nab whitespace.
1227(?:
1228\(                              #  (
1229[^\\\x80-\xff\n\015()] *                             #     normal*
1230(?:                                 #       (
1231(?:  \\ [^\x80-\xff]  |
1232\(                            #  (
1233[^\\\x80-\xff\n\015()] *                            #     normal*
1234(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1235\)                           #                       )
1236)    #         special
1237[^\\\x80-\xff\n\015()] *                         #         normal*
1238)*                                  #            )*
1239\)                             #                )
1240[\040\t]* )*    # If comment found, allow more spaces.
1241# optional trailing comments
1242(?:
1243\.
1244[\040\t]*                    # Nab whitespace.
1245(?:
1246\(                              #  (
1247[^\\\x80-\xff\n\015()] *                             #     normal*
1248(?:                                 #       (
1249(?:  \\ [^\x80-\xff]  |
1250\(                            #  (
1251[^\\\x80-\xff\n\015()] *                            #     normal*
1252(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1253\)                           #                       )
1254)    #         special
1255[^\\\x80-\xff\n\015()] *                         #         normal*
1256)*                                  #            )*
1257\)                             #                )
1258[\040\t]* )*    # If comment found, allow more spaces.
1259(?:
1260[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1261(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1262|
1263\[                            # [
1264(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1265\]                           #           ]
1266)
1267[\040\t]*                    # Nab whitespace.
1268(?:
1269\(                              #  (
1270[^\\\x80-\xff\n\015()] *                             #     normal*
1271(?:                                 #       (
1272(?:  \\ [^\x80-\xff]  |
1273\(                            #  (
1274[^\\\x80-\xff\n\015()] *                            #     normal*
1275(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1276\)                           #                       )
1277)    #         special
1278[^\\\x80-\xff\n\015()] *                         #         normal*
1279)*                                  #            )*
1280\)                             #                )
1281[\040\t]* )*    # If comment found, allow more spaces.
1282# optional trailing comments
1283)*
1284# address
1285|                             #  or
1286(?:
1287[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1288(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1289# Atom
1290|                       #  or
1291"                                     # "
1292[^\\\x80-\xff\n\015"] *                            #   normal
1293(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1294"                                     #        "
1295# Quoted string
1296)
1297# leading word
1298[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *               # "normal" atoms and or spaces
1299(?:
1300(?:
1301\(                              #  (
1302[^\\\x80-\xff\n\015()] *                             #     normal*
1303(?:                                 #       (
1304(?:  \\ [^\x80-\xff]  |
1305\(                            #  (
1306[^\\\x80-\xff\n\015()] *                            #     normal*
1307(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1308\)                           #                       )
1309)    #         special
1310[^\\\x80-\xff\n\015()] *                         #         normal*
1311)*                                  #            )*
1312\)                             #                )
1313|
1314"                                     # "
1315[^\\\x80-\xff\n\015"] *                            #   normal
1316(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1317"                                     #        "
1318) # "special" comment or quoted string
1319[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *            #  more "normal"
1320)*
1321<
1322[\040\t]*                    # Nab whitespace.
1323(?:
1324\(                              #  (
1325[^\\\x80-\xff\n\015()] *                             #     normal*
1326(?:                                 #       (
1327(?:  \\ [^\x80-\xff]  |
1328\(                            #  (
1329[^\\\x80-\xff\n\015()] *                            #     normal*
1330(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1331\)                           #                       )
1332)    #         special
1333[^\\\x80-\xff\n\015()] *                         #         normal*
1334)*                                  #            )*
1335\)                             #                )
1336[\040\t]* )*    # If comment found, allow more spaces.
1337# <
1338(?:
1339@
1340[\040\t]*                    # Nab whitespace.
1341(?:
1342\(                              #  (
1343[^\\\x80-\xff\n\015()] *                             #     normal*
1344(?:                                 #       (
1345(?:  \\ [^\x80-\xff]  |
1346\(                            #  (
1347[^\\\x80-\xff\n\015()] *                            #     normal*
1348(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1349\)                           #                       )
1350)    #         special
1351[^\\\x80-\xff\n\015()] *                         #         normal*
1352)*                                  #            )*
1353\)                             #                )
1354[\040\t]* )*    # If comment found, allow more spaces.
1355(?:
1356[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1357(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1358|
1359\[                            # [
1360(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1361\]                           #           ]
1362)
1363[\040\t]*                    # Nab whitespace.
1364(?:
1365\(                              #  (
1366[^\\\x80-\xff\n\015()] *                             #     normal*
1367(?:                                 #       (
1368(?:  \\ [^\x80-\xff]  |
1369\(                            #  (
1370[^\\\x80-\xff\n\015()] *                            #     normal*
1371(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1372\)                           #                       )
1373)    #         special
1374[^\\\x80-\xff\n\015()] *                         #         normal*
1375)*                                  #            )*
1376\)                             #                )
1377[\040\t]* )*    # If comment found, allow more spaces.
1378# optional trailing comments
1379(?:
1380\.
1381[\040\t]*                    # Nab whitespace.
1382(?:
1383\(                              #  (
1384[^\\\x80-\xff\n\015()] *                             #     normal*
1385(?:                                 #       (
1386(?:  \\ [^\x80-\xff]  |
1387\(                            #  (
1388[^\\\x80-\xff\n\015()] *                            #     normal*
1389(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1390\)                           #                       )
1391)    #         special
1392[^\\\x80-\xff\n\015()] *                         #         normal*
1393)*                                  #            )*
1394\)                             #                )
1395[\040\t]* )*    # If comment found, allow more spaces.
1396(?:
1397[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1398(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1399|
1400\[                            # [
1401(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1402\]                           #           ]
1403)
1404[\040\t]*                    # Nab whitespace.
1405(?:
1406\(                              #  (
1407[^\\\x80-\xff\n\015()] *                             #     normal*
1408(?:                                 #       (
1409(?:  \\ [^\x80-\xff]  |
1410\(                            #  (
1411[^\\\x80-\xff\n\015()] *                            #     normal*
1412(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1413\)                           #                       )
1414)    #         special
1415[^\\\x80-\xff\n\015()] *                         #         normal*
1416)*                                  #            )*
1417\)                             #                )
1418[\040\t]* )*    # If comment found, allow more spaces.
1419# optional trailing comments
1420)*
1421(?: ,
1422[\040\t]*                    # Nab whitespace.
1423(?:
1424\(                              #  (
1425[^\\\x80-\xff\n\015()] *                             #     normal*
1426(?:                                 #       (
1427(?:  \\ [^\x80-\xff]  |
1428\(                            #  (
1429[^\\\x80-\xff\n\015()] *                            #     normal*
1430(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1431\)                           #                       )
1432)    #         special
1433[^\\\x80-\xff\n\015()] *                         #         normal*
1434)*                                  #            )*
1435\)                             #                )
1436[\040\t]* )*    # If comment found, allow more spaces.
1437@
1438[\040\t]*                    # Nab whitespace.
1439(?:
1440\(                              #  (
1441[^\\\x80-\xff\n\015()] *                             #     normal*
1442(?:                                 #       (
1443(?:  \\ [^\x80-\xff]  |
1444\(                            #  (
1445[^\\\x80-\xff\n\015()] *                            #     normal*
1446(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1447\)                           #                       )
1448)    #         special
1449[^\\\x80-\xff\n\015()] *                         #         normal*
1450)*                                  #            )*
1451\)                             #                )
1452[\040\t]* )*    # If comment found, allow more spaces.
1453(?:
1454[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1455(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1456|
1457\[                            # [
1458(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1459\]                           #           ]
1460)
1461[\040\t]*                    # Nab whitespace.
1462(?:
1463\(                              #  (
1464[^\\\x80-\xff\n\015()] *                             #     normal*
1465(?:                                 #       (
1466(?:  \\ [^\x80-\xff]  |
1467\(                            #  (
1468[^\\\x80-\xff\n\015()] *                            #     normal*
1469(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1470\)                           #                       )
1471)    #         special
1472[^\\\x80-\xff\n\015()] *                         #         normal*
1473)*                                  #            )*
1474\)                             #                )
1475[\040\t]* )*    # If comment found, allow more spaces.
1476# optional trailing comments
1477(?:
1478\.
1479[\040\t]*                    # Nab whitespace.
1480(?:
1481\(                              #  (
1482[^\\\x80-\xff\n\015()] *                             #     normal*
1483(?:                                 #       (
1484(?:  \\ [^\x80-\xff]  |
1485\(                            #  (
1486[^\\\x80-\xff\n\015()] *                            #     normal*
1487(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1488\)                           #                       )
1489)    #         special
1490[^\\\x80-\xff\n\015()] *                         #         normal*
1491)*                                  #            )*
1492\)                             #                )
1493[\040\t]* )*    # If comment found, allow more spaces.
1494(?:
1495[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1496(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1497|
1498\[                            # [
1499(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1500\]                           #           ]
1501)
1502[\040\t]*                    # Nab whitespace.
1503(?:
1504\(                              #  (
1505[^\\\x80-\xff\n\015()] *                             #     normal*
1506(?:                                 #       (
1507(?:  \\ [^\x80-\xff]  |
1508\(                            #  (
1509[^\\\x80-\xff\n\015()] *                            #     normal*
1510(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1511\)                           #                       )
1512)    #         special
1513[^\\\x80-\xff\n\015()] *                         #         normal*
1514)*                                  #            )*
1515\)                             #                )
1516[\040\t]* )*    # If comment found, allow more spaces.
1517# optional trailing comments
1518)*
1519)*  # additional domains
1520:
1521[\040\t]*                    # Nab whitespace.
1522(?:
1523\(                              #  (
1524[^\\\x80-\xff\n\015()] *                             #     normal*
1525(?:                                 #       (
1526(?:  \\ [^\x80-\xff]  |
1527\(                            #  (
1528[^\\\x80-\xff\n\015()] *                            #     normal*
1529(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1530\)                           #                       )
1531)    #         special
1532[^\\\x80-\xff\n\015()] *                         #         normal*
1533)*                                  #            )*
1534\)                             #                )
1535[\040\t]* )*    # If comment found, allow more spaces.
1536# optional trailing comments
1537)?     #       optional route
1538(?:
1539[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1540(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1541# Atom
1542|                       #  or
1543"                                     # "
1544[^\\\x80-\xff\n\015"] *                            #   normal
1545(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1546"                                     #        "
1547# Quoted string
1548)
1549[\040\t]*                    # Nab whitespace.
1550(?:
1551\(                              #  (
1552[^\\\x80-\xff\n\015()] *                             #     normal*
1553(?:                                 #       (
1554(?:  \\ [^\x80-\xff]  |
1555\(                            #  (
1556[^\\\x80-\xff\n\015()] *                            #     normal*
1557(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1558\)                           #                       )
1559)    #         special
1560[^\\\x80-\xff\n\015()] *                         #         normal*
1561)*                                  #            )*
1562\)                             #                )
1563[\040\t]* )*    # If comment found, allow more spaces.
1564(?:
1565\.
1566[\040\t]*                    # Nab whitespace.
1567(?:
1568\(                              #  (
1569[^\\\x80-\xff\n\015()] *                             #     normal*
1570(?:                                 #       (
1571(?:  \\ [^\x80-\xff]  |
1572\(                            #  (
1573[^\\\x80-\xff\n\015()] *                            #     normal*
1574(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1575\)                           #                       )
1576)    #         special
1577[^\\\x80-\xff\n\015()] *                         #         normal*
1578)*                                  #            )*
1579\)                             #                )
1580[\040\t]* )*    # If comment found, allow more spaces.
1581(?:
1582[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1583(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1584# Atom
1585|                       #  or
1586"                                     # "
1587[^\\\x80-\xff\n\015"] *                            #   normal
1588(?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1589"                                     #        "
1590# Quoted string
1591)
1592[\040\t]*                    # Nab whitespace.
1593(?:
1594\(                              #  (
1595[^\\\x80-\xff\n\015()] *                             #     normal*
1596(?:                                 #       (
1597(?:  \\ [^\x80-\xff]  |
1598\(                            #  (
1599[^\\\x80-\xff\n\015()] *                            #     normal*
1600(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1601\)                           #                       )
1602)    #         special
1603[^\\\x80-\xff\n\015()] *                         #         normal*
1604)*                                  #            )*
1605\)                             #                )
1606[\040\t]* )*    # If comment found, allow more spaces.
1607# additional words
1608)*
1609@
1610[\040\t]*                    # Nab whitespace.
1611(?:
1612\(                              #  (
1613[^\\\x80-\xff\n\015()] *                             #     normal*
1614(?:                                 #       (
1615(?:  \\ [^\x80-\xff]  |
1616\(                            #  (
1617[^\\\x80-\xff\n\015()] *                            #     normal*
1618(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1619\)                           #                       )
1620)    #         special
1621[^\\\x80-\xff\n\015()] *                         #         normal*
1622)*                                  #            )*
1623\)                             #                )
1624[\040\t]* )*    # If comment found, allow more spaces.
1625(?:
1626[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1627(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1628|
1629\[                            # [
1630(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1631\]                           #           ]
1632)
1633[\040\t]*                    # Nab whitespace.
1634(?:
1635\(                              #  (
1636[^\\\x80-\xff\n\015()] *                             #     normal*
1637(?:                                 #       (
1638(?:  \\ [^\x80-\xff]  |
1639\(                            #  (
1640[^\\\x80-\xff\n\015()] *                            #     normal*
1641(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1642\)                           #                       )
1643)    #         special
1644[^\\\x80-\xff\n\015()] *                         #         normal*
1645)*                                  #            )*
1646\)                             #                )
1647[\040\t]* )*    # If comment found, allow more spaces.
1648# optional trailing comments
1649(?:
1650\.
1651[\040\t]*                    # Nab whitespace.
1652(?:
1653\(                              #  (
1654[^\\\x80-\xff\n\015()] *                             #     normal*
1655(?:                                 #       (
1656(?:  \\ [^\x80-\xff]  |
1657\(                            #  (
1658[^\\\x80-\xff\n\015()] *                            #     normal*
1659(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1660\)                           #                       )
1661)    #         special
1662[^\\\x80-\xff\n\015()] *                         #         normal*
1663)*                                  #            )*
1664\)                             #                )
1665[\040\t]* )*    # If comment found, allow more spaces.
1666(?:
1667[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1668(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1669|
1670\[                            # [
1671(?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1672\]                           #           ]
1673)
1674[\040\t]*                    # Nab whitespace.
1675(?:
1676\(                              #  (
1677[^\\\x80-\xff\n\015()] *                             #     normal*
1678(?:                                 #       (
1679(?:  \\ [^\x80-\xff]  |
1680\(                            #  (
1681[^\\\x80-\xff\n\015()] *                            #     normal*
1682(?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1683\)                           #                       )
1684)    #         special
1685[^\\\x80-\xff\n\015()] *                         #         normal*
1686)*                                  #            )*
1687\)                             #                )
1688[\040\t]* )*    # If comment found, allow more spaces.
1689# optional trailing comments
1690)*
1691#       address spec
1692>                    #                 >
1693# name and address
1694)
1695/x
1696    Alan Other <user\@dom.ain>
1697 0: Alan Other <user@dom.ain>
1698    <user\@dom.ain>
1699 0: user@dom.ain
1700    user\@dom.ain
1701 0: user@dom.ain
1702    \"A. Other\" <user.1234\@dom.ain> (a comment)
1703 0: "A. Other" <user.1234@dom.ain>
1704    A. Other <user.1234\@dom.ain> (a comment)
1705 0:  Other <user.1234@dom.ain>
1706    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
1707 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
1708    A missing angle <user\@some.where
1709 0: user@some.where
1710\= Expect no match
1711    The quick brown fox
1712No match
1713
1714/abc\0def\00pqr\000xyz\0000AB/
1715    abc\0def\00pqr\000xyz\0000AB
1716 0: abc\x00def\x00pqr\x00xyz\x000AB
1717    abc456 abc\0def\00pqr\000xyz\0000ABCDE
1718 0: abc\x00def\x00pqr\x00xyz\x000AB
1719
1720/abc\x0def\x00pqr\x000xyz\x0000AB/
1721    abc\x0def\x00pqr\x000xyz\x0000AB
1722 0: abc\x0def\x00pqr\x000xyz\x0000AB
1723    abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
1724 0: abc\x0def\x00pqr\x000xyz\x0000AB
1725
1726/^[\000-\037]/
1727    \0A
1728 0: \x00
1729    \01B
1730 0: \x01
1731    \037C
1732 0: \x1f
1733
1734/\0*/
1735    \0\0\0\0
1736 0: \x00\x00\x00\x00
1737
1738/A\x0{2,3}Z/
1739    The A\x0\x0Z
1740 0: A\x00\x00Z
1741    An A\0\x0\0Z
1742 0: A\x00\x00\x00Z
1743\= Expect no match
1744    A\0Z
1745No match
1746    A\0\x0\0\x0Z
1747No match
1748
1749/^(cow|)\1(bell)/
1750    cowcowbell
1751 0: cowcowbell
1752 1: cow
1753 2: bell
1754    bell
1755 0: bell
1756 1:
1757 2: bell
1758\= Expect no match
1759    cowbell
1760No match
1761
1762/^\s/
1763    \040abc
1764 0:
1765    \x0cabc
1766 0: \x0c
1767    \nabc
1768 0: \x0a
1769    \rabc
1770 0: \x0d
1771    \tabc
1772 0: \x09
1773\= Expect no match
1774    abc
1775No match
1776
1777/^a	b
1778      c/x
1779    abc
1780 0: abc
1781
1782/^(a|)\1*b/
1783    ab
1784 0: ab
1785 1: a
1786    aaaab
1787 0: aaaab
1788 1: a
1789    b
1790 0: b
1791 1:
1792\= Expect no match
1793    acb
1794No match
1795
1796/^(a|)\1+b/
1797    aab
1798 0: aab
1799 1: a
1800    aaaab
1801 0: aaaab
1802 1: a
1803    b
1804 0: b
1805 1:
1806\= Expect no match
1807    ab
1808No match
1809
1810/^(a|)\1?b/
1811    ab
1812 0: ab
1813 1: a
1814    aab
1815 0: aab
1816 1: a
1817    b
1818 0: b
1819 1:
1820\= Expect no match
1821    acb
1822No match
1823
1824/^(a|)\1{2}b/
1825    aaab
1826 0: aaab
1827 1: a
1828    b
1829 0: b
1830 1:
1831\= Expect no match
1832    ab
1833No match
1834    aab
1835No match
1836    aaaab
1837No match
1838
1839/^(a|)\1{2,3}b/
1840    aaab
1841 0: aaab
1842 1: a
1843    aaaab
1844 0: aaaab
1845 1: a
1846    b
1847 0: b
1848 1:
1849\= Expect no match
1850    ab
1851No match
1852    aab
1853No match
1854    aaaaab
1855No match
1856
1857/ab{1,3}bc/
1858    abbbbc
1859 0: abbbbc
1860    abbbc
1861 0: abbbc
1862    abbc
1863 0: abbc
1864\= Expect no match
1865    abc
1866No match
1867    abbbbbc
1868No match
1869
1870/([^.]*)\.([^:]*):[T ]+(.*)/
1871    track1.title:TBlah blah blah
1872 0: track1.title:TBlah blah blah
1873 1: track1
1874 2: title
1875 3: Blah blah blah
1876
1877/([^.]*)\.([^:]*):[T ]+(.*)/i
1878    track1.title:TBlah blah blah
1879 0: track1.title:TBlah blah blah
1880 1: track1
1881 2: title
1882 3: Blah blah blah
1883
1884/([^.]*)\.([^:]*):[t ]+(.*)/i
1885    track1.title:TBlah blah blah
1886 0: track1.title:TBlah blah blah
1887 1: track1
1888 2: title
1889 3: Blah blah blah
1890
1891/^[W-c]+$/
1892    WXY_^abc
1893 0: WXY_^abc
1894\= Expect no match
1895    wxy
1896No match
1897
1898/^[W-c]+$/i
1899    WXY_^abc
1900 0: WXY_^abc
1901    wxy_^ABC
1902 0: wxy_^ABC
1903
1904/^[\x3f-\x5F]+$/i
1905    WXY_^abc
1906 0: WXY_^abc
1907    wxy_^ABC
1908 0: wxy_^ABC
1909
1910/^abc$/m
1911    abc
1912 0: abc
1913    qqq\nabc
1914 0: abc
1915    abc\nzzz
1916 0: abc
1917    qqq\nabc\nzzz
1918 0: abc
1919
1920/^abc$/
1921    abc
1922 0: abc
1923\= Expect no match
1924    qqq\nabc
1925No match
1926    abc\nzzz
1927No match
1928    qqq\nabc\nzzz
1929No match
1930
1931/\Aabc\Z/m
1932    abc
1933 0: abc
1934    abc\n
1935 0: abc
1936\= Expect no match
1937    qqq\nabc
1938No match
1939    abc\nzzz
1940No match
1941    qqq\nabc\nzzz
1942No match
1943
1944/\A(.)*\Z/s
1945    abc\ndef
1946 0: abc\x0adef
1947 1: f
1948
1949/\A(.)*\Z/m
1950\= Expect no match
1951    abc\ndef
1952No match
1953
1954/(?:b)|(?::+)/
1955    b::c
1956 0: b
1957    c::b
1958 0: ::
1959
1960/[-az]+/
1961    az-
1962 0: az-
1963\= Expect no match
1964    b
1965No match
1966
1967/[az-]+/
1968    za-
1969 0: za-
1970\= Expect no match
1971    b
1972No match
1973
1974/[a\-z]+/
1975    a-z
1976 0: a-z
1977\= Expect no match
1978    b
1979No match
1980
1981/[a-z]+/
1982    abcdxyz
1983 0: abcdxyz
1984
1985/[\d-]+/
1986    12-34
1987 0: 12-34
1988\= Expect no match
1989    aaa
1990No match
1991
1992/\x5c/
1993    \\
1994 0: \
1995
1996/\x20Z/
1997    the Zoo
1998 0:  Z
1999\= Expect no match
2000    Zulu
2001No match
2002
2003/(abc)\1/i
2004    abcabc
2005 0: abcabc
2006 1: abc
2007    ABCabc
2008 0: ABCabc
2009 1: ABC
2010    abcABC
2011 0: abcABC
2012 1: abc
2013
2014/abc$/
2015    abc
2016 0: abc
2017    abc\n
2018 0: abc
2019\= Expect no match
2020    abc\ndef
2021No match
2022
2023/(abc)\123/
2024    abc\x53
2025 0: abcS
2026 1: abc
2027
2028/(abc)\223/
2029    abc\x93
2030 0: abc\x93
2031 1: abc
2032
2033/(abc)\323/
2034    abc\xd3
2035 0: abc\xd3
2036 1: abc
2037
2038/(abc)\100/
2039    abc\x40
2040 0: abc@
2041 1: abc
2042    abc\100
2043 0: abc@
2044 1: abc
2045
2046/(abc)\1000/
2047    abc\x400
2048 0: abc@0
2049 1: abc
2050    abc\x40\x30
2051 0: abc@0
2052 1: abc
2053    abc\1000
2054 0: abc@0
2055 1: abc
2056    abc\100\x30
2057 0: abc@0
2058 1: abc
2059    abc\100\060
2060 0: abc@0
2061 1: abc
2062    abc\100\60
2063 0: abc@0
2064 1: abc
2065
2066/^(A)(B)(C)(D)(E)(F)(G)(H)(I)\8\9$/
2067    ABCDEFGHIHI
2068 0: ABCDEFGHIHI
2069 1: A
2070 2: B
2071 3: C
2072 4: D
2073 5: E
2074 6: F
2075 7: G
2076 8: H
2077 9: I
2078
2079/^[A\8B\9C]+$/
2080    A8B9C
2081 0: A8B9C
2082\= Expect no match
2083    A8B9C\x00
2084No match
2085
2086/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
2087    abcdefghijkllS
2088 0: abcdefghijkllS
2089 1: a
2090 2: b
2091 3: c
2092 4: d
2093 5: e
2094 6: f
2095 7: g
2096 8: h
2097 9: i
209810: j
209911: k
210012: l
2101
2102/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
2103    abcdefghijk\12S
2104 0: abcdefghijk\x0aS
2105 1: a
2106 2: b
2107 3: c
2108 4: d
2109 5: e
2110 6: f
2111 7: g
2112 8: h
2113 9: i
211410: j
211511: k
2116
2117/a{0}bc/
2118    bc
2119 0: bc
2120
2121/(a|(bc)){0,0}?xyz/
2122    xyz
2123 0: xyz
2124
2125/abc[\10]de/
2126    abc\010de
2127 0: abc\x08de
2128
2129/abc[\1]de/
2130    abc\1de
2131 0: abc\x01de
2132
2133/(abc)[\1]de/
2134    abc\1de
2135 0: abc\x01de
2136 1: abc
2137
2138/(?s)a.b/
2139    a\nb
2140 0: a\x0ab
2141
2142/^([^a])([^\b])([^c]*)([^d]{3,4})/
2143    baNOTccccd
2144 0: baNOTcccc
2145 1: b
2146 2: a
2147 3: NOT
2148 4: cccc
2149    baNOTcccd
2150 0: baNOTccc
2151 1: b
2152 2: a
2153 3: NOT
2154 4: ccc
2155    baNOTccd
2156 0: baNOTcc
2157 1: b
2158 2: a
2159 3: NO
2160 4: Tcc
2161    bacccd
2162 0: baccc
2163 1: b
2164 2: a
2165 3:
2166 4: ccc
2167\= Expect no match
2168    anything
2169No match
2170    b\bc
2171No match
2172    baccd
2173No match
2174
2175/[^a]/
2176    Abc
2177 0: A
2178
2179/[^a]/i
2180    Abc
2181 0: b
2182
2183/[^a]+/
2184    AAAaAbc
2185 0: AAA
2186
2187/[^a]+/i
2188    AAAaAbc
2189 0: bc
2190
2191/[^a]+/
2192    bbb\nccc
2193 0: bbb\x0accc
2194
2195/[^k]$/
2196    abc
2197 0: c
2198\= Expect no match
2199    abk
2200No match
2201
2202/[^k]{2,3}$/
2203    abc
2204 0: abc
2205    kbc
2206 0: bc
2207    kabc
2208 0: abc
2209\= Expect no match
2210    abk
2211No match
2212    akb
2213No match
2214    akk
2215No match
2216
2217/^\d{8,}\@.+[^k]$/
2218    12345678\@a.b.c.d
2219 0: 12345678@a.b.c.d
2220    123456789\@x.y.z
2221 0: 123456789@x.y.z
2222\= Expect no match
2223    12345678\@x.y.uk
2224No match
2225    1234567\@a.b.c.d
2226No match
2227
2228/(a)\1{8,}/
2229    aaaaaaaaa
2230 0: aaaaaaaaa
2231 1: a
2232    aaaaaaaaaa
2233 0: aaaaaaaaaa
2234 1: a
2235\= Expect no match
2236    aaaaaaa
2237No match
2238
2239/[^a]/
2240    aaaabcd
2241 0: b
2242    aaAabcd
2243 0: A
2244
2245/[^a]/i
2246    aaaabcd
2247 0: b
2248    aaAabcd
2249 0: b
2250
2251/[^az]/
2252    aaaabcd
2253 0: b
2254    aaAabcd
2255 0: A
2256
2257/[^az]/i
2258    aaaabcd
2259 0: b
2260    aaAabcd
2261 0: b
2262
2263/\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377/
2264 \000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377
2265 0: \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff
2266
2267/P[^*]TAIRE[^*]{1,6}?LL/
2268    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
2269 0: PSTAIREISLL
2270
2271/P[^*]TAIRE[^*]{1,}?LL/
2272    xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
2273 0: PSTAIREISLL
2274
2275/(\.\d\d[1-9]?)\d+/
2276    1.230003938
2277 0: .230003938
2278 1: .23
2279    1.875000282
2280 0: .875000282
2281 1: .875
2282    1.235
2283 0: .235
2284 1: .23
2285
2286/(\.\d\d((?=0)|\d(?=\d)))/
2287    1.230003938
2288 0: .23
2289 1: .23
2290 2:
2291    1.875000282
2292 0: .875
2293 1: .875
2294 2: 5
2295\= Expect no match
2296    1.235
2297No match
2298
2299/a(?)b/
2300    ab
2301 0: ab
2302
2303/\b(foo)\s+(\w+)/i
2304    Food is on the foo table
2305 0: foo table
2306 1: foo
2307 2: table
2308
2309/foo(.*)bar/
2310    The food is under the bar in the barn.
2311 0: food is under the bar in the bar
2312 1: d is under the bar in the
2313
2314/foo(.*?)bar/
2315    The food is under the bar in the barn.
2316 0: food is under the bar
2317 1: d is under the
2318
2319/(.*)(\d*)/
2320    I have 2 numbers: 53147
2321 0: I have 2 numbers: 53147
2322 1: I have 2 numbers: 53147
2323 2:
2324
2325/(.*)(\d+)/
2326    I have 2 numbers: 53147
2327 0: I have 2 numbers: 53147
2328 1: I have 2 numbers: 5314
2329 2: 7
2330
2331/(.*?)(\d*)/
2332    I have 2 numbers: 53147
2333 0:
2334 1:
2335 2:
2336
2337/(.*?)(\d+)/
2338    I have 2 numbers: 53147
2339 0: I have 2
2340 1: I have
2341 2: 2
2342
2343/(.*)(\d+)$/
2344    I have 2 numbers: 53147
2345 0: I have 2 numbers: 53147
2346 1: I have 2 numbers: 5314
2347 2: 7
2348
2349/(.*?)(\d+)$/
2350    I have 2 numbers: 53147
2351 0: I have 2 numbers: 53147
2352 1: I have 2 numbers:
2353 2: 53147
2354
2355/(.*)\b(\d+)$/
2356    I have 2 numbers: 53147
2357 0: I have 2 numbers: 53147
2358 1: I have 2 numbers:
2359 2: 53147
2360
2361/(.*\D)(\d+)$/
2362    I have 2 numbers: 53147
2363 0: I have 2 numbers: 53147
2364 1: I have 2 numbers:
2365 2: 53147
2366
2367/^\D*(?!123)/
2368    ABC123
2369 0: AB
2370
2371/^(\D*)(?=\d)(?!123)/
2372    ABC445
2373 0: ABC
2374 1: ABC
2375\= Expect no match
2376    ABC123
2377No match
2378
2379/^[W-]46]/
2380    W46]789
2381 0: W46]
2382    -46]789
2383 0: -46]
2384\= Expect no match
2385    Wall
2386No match
2387    Zebra
2388No match
2389    42
2390No match
2391    [abcd]
2392No match
2393    ]abcd[
2394No match
2395
2396/^[W-\]46]/
2397    W46]789
2398 0: W
2399    Wall
2400 0: W
2401    Zebra
2402 0: Z
2403    Xylophone
2404 0: X
2405    42
2406 0: 4
2407    [abcd]
2408 0: [
2409    ]abcd[
2410 0: ]
2411    \\backslash
2412 0: \
2413\= Expect no match
2414    -46]789
2415No match
2416    well
2417No match
2418
2419/\d\d\/\d\d\/\d\d\d\d/
2420    01/01/2000
2421 0: 01/01/2000
2422
2423/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
2424    word cat dog elephant mussel cow horse canary baboon snake shark otherword
2425 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
2426\= Expect no match
2427    word cat dog elephant mussel cow horse canary baboon snake shark
2428No match
2429
2430/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
2431\= Expect no match
2432    word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
2433No match
2434
2435/^(a){0,0}/
2436    bcd
2437 0:
2438    abc
2439 0:
2440    aab
2441 0:
2442
2443/^(a){0,1}/
2444    bcd
2445 0:
2446    abc
2447 0: a
2448 1: a
2449    aab
2450 0: a
2451 1: a
2452
2453/^(a){0,2}/
2454    bcd
2455 0:
2456    abc
2457 0: a
2458 1: a
2459    aab
2460 0: aa
2461 1: a
2462
2463/^(a){0,3}/
2464    bcd
2465 0:
2466    abc
2467 0: a
2468 1: a
2469    aab
2470 0: aa
2471 1: a
2472    aaa
2473 0: aaa
2474 1: a
2475
2476/^(a){0,}/
2477    bcd
2478 0:
2479    abc
2480 0: a
2481 1: a
2482    aab
2483 0: aa
2484 1: a
2485    aaa
2486 0: aaa
2487 1: a
2488    aaaaaaaa
2489 0: aaaaaaaa
2490 1: a
2491
2492/^(a){1,1}/
2493    abc
2494 0: a
2495 1: a
2496    aab
2497 0: a
2498 1: a
2499\= Expect no match
2500    bcd
2501No match
2502
2503/^(a){1,2}/
2504    abc
2505 0: a
2506 1: a
2507    aab
2508 0: aa
2509 1: a
2510\= Expect no match
2511    bcd
2512No match
2513
2514/^(a){1,3}/
2515    abc
2516 0: a
2517 1: a
2518    aab
2519 0: aa
2520 1: a
2521    aaa
2522 0: aaa
2523 1: a
2524\= Expect no match
2525    bcd
2526No match
2527
2528/^(a){1,}/
2529    abc
2530 0: a
2531 1: a
2532    aab
2533 0: aa
2534 1: a
2535    aaa
2536 0: aaa
2537 1: a
2538    aaaaaaaa
2539 0: aaaaaaaa
2540 1: a
2541\= Expect no match
2542    bcd
2543No match
2544
2545/.*\.gif/
2546    borfle\nbib.gif\nno
2547 0: bib.gif
2548
2549/.{0,}\.gif/
2550    borfle\nbib.gif\nno
2551 0: bib.gif
2552
2553/.*\.gif/m
2554    borfle\nbib.gif\nno
2555 0: bib.gif
2556
2557/.*\.gif/s
2558    borfle\nbib.gif\nno
2559 0: borfle\x0abib.gif
2560
2561/.*\.gif/ms
2562    borfle\nbib.gif\nno
2563 0: borfle\x0abib.gif
2564
2565/.*$/
2566    borfle\nbib.gif\nno
2567 0: no
2568
2569/.*$/m
2570    borfle\nbib.gif\nno
2571 0: borfle
2572
2573/.*$/s
2574    borfle\nbib.gif\nno
2575 0: borfle\x0abib.gif\x0ano
2576
2577/.*$/ms
2578    borfle\nbib.gif\nno
2579 0: borfle\x0abib.gif\x0ano
2580
2581/.*$/
2582    borfle\nbib.gif\nno\n
2583 0: no
2584
2585/.*$/m
2586    borfle\nbib.gif\nno\n
2587 0: borfle
2588
2589/.*$/s
2590    borfle\nbib.gif\nno\n
2591 0: borfle\x0abib.gif\x0ano\x0a
2592
2593/.*$/ms
2594    borfle\nbib.gif\nno\n
2595 0: borfle\x0abib.gif\x0ano\x0a
2596
2597/(.*X|^B)/
2598    abcde\n1234Xyz
2599 0: 1234X
2600 1: 1234X
2601    BarFoo
2602 0: B
2603 1: B
2604\= Expect no match
2605    abcde\nBar
2606No match
2607
2608/(.*X|^B)/m
2609    abcde\n1234Xyz
2610 0: 1234X
2611 1: 1234X
2612    BarFoo
2613 0: B
2614 1: B
2615    abcde\nBar
2616 0: B
2617 1: B
2618
2619/(.*X|^B)/s
2620    abcde\n1234Xyz
2621 0: abcde\x0a1234X
2622 1: abcde\x0a1234X
2623    BarFoo
2624 0: B
2625 1: B
2626\= Expect no match
2627    abcde\nBar
2628No match
2629
2630/(.*X|^B)/ms
2631    abcde\n1234Xyz
2632 0: abcde\x0a1234X
2633 1: abcde\x0a1234X
2634    BarFoo
2635 0: B
2636 1: B
2637    abcde\nBar
2638 0: B
2639 1: B
2640
2641/(?s)(.*X|^B)/
2642    abcde\n1234Xyz
2643 0: abcde\x0a1234X
2644 1: abcde\x0a1234X
2645    BarFoo
2646 0: B
2647 1: B
2648\= Expect no match
2649    abcde\nBar
2650No match
2651
2652/(?s:.*X|^B)/
2653    abcde\n1234Xyz
2654 0: abcde\x0a1234X
2655    BarFoo
2656 0: B
2657\= Expect no match
2658    abcde\nBar
2659No match
2660
2661/^.*B/
2662\= Expect no match
2663    abc\nB
2664No match
2665
2666/(?s)^.*B/
2667    abc\nB
2668 0: abc\x0aB
2669
2670/(?m)^.*B/
2671    abc\nB
2672 0: B
2673
2674/(?ms)^.*B/
2675    abc\nB
2676 0: abc\x0aB
2677
2678/(?ms)^B/
2679    abc\nB
2680 0: B
2681
2682/(?s)B$/
2683    B\n
2684 0: B
2685
2686/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
2687    123456654321
2688 0: 123456654321
2689
2690/^\d\d\d\d\d\d\d\d\d\d\d\d/
2691    123456654321
2692 0: 123456654321
2693
2694/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
2695    123456654321
2696 0: 123456654321
2697
2698/^[abc]{12}/
2699    abcabcabcabc
2700 0: abcabcabcabc
2701
2702/^[a-c]{12}/
2703    abcabcabcabc
2704 0: abcabcabcabc
2705
2706/^(a|b|c){12}/
2707    abcabcabcabc
2708 0: abcabcabcabc
2709 1: c
2710
2711/^[abcdefghijklmnopqrstuvwxy0123456789]/
2712    n
2713 0: n
2714\= Expect no match
2715    z
2716No match
2717
2718/abcde{0,0}/
2719    abcd
2720 0: abcd
2721\= Expect no match
2722    abce
2723No match
2724
2725/ab[cd]{0,0}e/
2726    abe
2727 0: abe
2728\= Expect no match
2729    abcde
2730No match
2731
2732/ab(c){0,0}d/
2733    abd
2734 0: abd
2735\= Expect no match
2736    abcd
2737No match
2738
2739/a(b*)/
2740    a
2741 0: a
2742 1:
2743    ab
2744 0: ab
2745 1: b
2746    abbbb
2747 0: abbbb
2748 1: bbbb
2749\= Expect no match
2750    bbbbb
2751No match
2752
2753/ab\d{0}e/
2754    abe
2755 0: abe
2756\= Expect no match
2757    ab1e
2758No match
2759
2760/"([^\\"]+|\\.)*"/
2761    the \"quick\" brown fox
2762 0: "quick"
2763 1: quick
2764    \"the \\\"quick\\\" brown fox\"
2765 0: "the \"quick\" brown fox"
2766 1:  brown fox
2767
2768/.*?/g,aftertext
2769    abc
2770 0:
2771 0+ abc
2772 0: a
2773 0+ bc
2774 0:
2775 0+ bc
2776 0: b
2777 0+ c
2778 0:
2779 0+ c
2780 0: c
2781 0+
2782 0:
2783 0+
2784
2785/\b/g,aftertext
2786    abc
2787 0:
2788 0+ abc
2789 0:
2790 0+
2791
2792/\b/g,aftertext
2793    abc
2794 0:
2795 0+ abc
2796 0:
2797 0+
2798
2799//g
2800    abc
2801 0:
2802 0:
2803 0:
2804 0:
2805
2806/<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>/is
2807  <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
2808 0: <TR BGCOLOR='#DBE9E9'><TD align=left valign=top>43.<a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)</a></TD><TD align=left valign=top>Lega lstaff.com</TD><TD align=left valign=top>CA - Statewide</TD></TR>
2809 1:  BGCOLOR='#DBE9E9'
2810 2:  align=left valign=top
2811 3: 43.
2812 4: <a href='joblist.cfm?JobID=94 6735&Keyword='>Word Processor<BR>(N-1286)
2813 5:
2814 6:
2815 7: <unset>
2816 8:  align=left valign=top
2817 9: Lega lstaff.com
281810:  align=left valign=top
281911: CA - Statewide
2820
2821/a[^a]b/
2822    acb
2823 0: acb
2824    a\nb
2825 0: a\x0ab
2826
2827/a.b/
2828    acb
2829 0: acb
2830\= Expect no match
2831    a\nb
2832No match
2833
2834/a[^a]b/s
2835    acb
2836 0: acb
2837    a\nb
2838 0: a\x0ab
2839
2840/a.b/s
2841    acb
2842 0: acb
2843    a\nb
2844 0: a\x0ab
2845
2846/^(b+?|a){1,2}?c/
2847    bac
2848 0: bac
2849 1: a
2850    bbac
2851 0: bbac
2852 1: a
2853    bbbac
2854 0: bbbac
2855 1: a
2856    bbbbac
2857 0: bbbbac
2858 1: a
2859    bbbbbac
2860 0: bbbbbac
2861 1: a
2862
2863/^(b+|a){1,2}?c/
2864    bac
2865 0: bac
2866 1: a
2867    bbac
2868 0: bbac
2869 1: a
2870    bbbac
2871 0: bbbac
2872 1: a
2873    bbbbac
2874 0: bbbbac
2875 1: a
2876    bbbbbac
2877 0: bbbbbac
2878 1: a
2879
2880/(?!\A)x/m
2881    a\bx\n
2882 0: x
2883    a\nx\n
2884 0: x
2885\= Expect no match
2886    x\nb\n
2887No match
2888
2889/(A|B)*?CD/
2890    CD
2891 0: CD
2892
2893/(A|B)*CD/
2894    CD
2895 0: CD
2896
2897/(AB)*?\1/
2898    ABABAB
2899 0: ABAB
2900 1: AB
2901
2902/(AB)*\1/
2903    ABABAB
2904 0: ABABAB
2905 1: AB
2906
2907/(?<!bar)foo/
2908    foo
2909 0: foo
2910    catfood
2911 0: foo
2912    arfootle
2913 0: foo
2914    rfoosh
2915 0: foo
2916\= Expect no match
2917    barfoo
2918No match
2919    towbarfoo
2920No match
2921
2922/\w{3}(?<!bar)foo/
2923    catfood
2924 0: catfoo
2925\= Expect no match
2926    foo
2927No match
2928    barfoo
2929No match
2930    towbarfoo
2931No match
2932
2933/(?<=(foo)a)bar/
2934    fooabar
2935 0: bar
2936 1: foo
2937\= Expect no match
2938    bar
2939No match
2940    foobbar
2941No match
2942
2943/\Aabc\z/m
2944    abc
2945 0: abc
2946\= Expect no match
2947    abc\n
2948No match
2949    qqq\nabc
2950No match
2951    abc\nzzz
2952No match
2953    qqq\nabc\nzzz
2954No match
2955
2956/(?>.*\/)foo/
2957    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
2958 0: /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
2959\= Expect no match
2960    /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
2961No match
2962
2963/(?>(\.\d\d[1-9]?))\d+/
2964    1.230003938
2965 0: .230003938
2966 1: .23
2967    1.875000282
2968 0: .875000282
2969 1: .875
2970\= Expect no match
2971    1.235
2972No match
2973
2974/^((?>\w+)|(?>\s+))*$/
2975    now is the time for all good men to come to the aid of the party
2976 0: now is the time for all good men to come to the aid of the party
2977 1: party
2978\= Expect no match
2979    this is not a line with only words and spaces!
2980No match
2981
2982/(\d+)(\w)/
2983    12345a
2984 0: 12345a
2985 1: 12345
2986 2: a
2987    12345+
2988 0: 12345
2989 1: 1234
2990 2: 5
2991
2992/((?>\d+))(\w)/
2993    12345a
2994 0: 12345a
2995 1: 12345
2996 2: a
2997\= Expect no match
2998    12345+
2999No match
3000
3001/(?>a+)b/
3002    aaab
3003 0: aaab
3004
3005/((?>a+)b)/
3006    aaab
3007 0: aaab
3008 1: aaab
3009
3010/(?>(a+))b/
3011    aaab
3012 0: aaab
3013 1: aaa
3014
3015/(?>b)+/
3016    aaabbbccc
3017 0: bbb
3018
3019/(?>a+|b+|c+)*c/
3020    aaabbbbccccd
3021 0: aaabbbbc
3022
3023/((?>[^()]+)|\([^()]*\))+/
3024    ((abc(ade)ufh()()x
3025 0: abc(ade)ufh()()x
3026 1: x
3027
3028/\(((?>[^()]+)|\([^()]+\))+\)/
3029    (abc)
3030 0: (abc)
3031 1: abc
3032    (abc(def)xyz)
3033 0: (abc(def)xyz)
3034 1: xyz
3035\= Expect no match
3036    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
3037No match
3038
3039/a(?-i)b/i
3040    ab
3041 0: ab
3042    Ab
3043 0: Ab
3044\= Expect no match
3045    aB
3046No match
3047    AB
3048No match
3049
3050/(a (?x)b c)d e/
3051    a bcd e
3052 0: a bcd e
3053 1: a bc
3054\= Expect no match
3055    a b cd e
3056No match
3057    abcd e
3058No match
3059    a bcde
3060No match
3061
3062/(a b(?x)c d (?-x)e f)/
3063    a bcde f
3064 0: a bcde f
3065 1: a bcde f
3066\= Expect no match
3067    abcdef
3068No match
3069
3070/(a(?i)b)c/
3071    abc
3072 0: abc
3073 1: ab
3074    aBc
3075 0: aBc
3076 1: aB
3077\= Expect no match
3078    abC
3079No match
3080    aBC
3081No match
3082    Abc
3083No match
3084    ABc
3085No match
3086    ABC
3087No match
3088    AbC
3089No match
3090
3091/a(?i:b)c/
3092    abc
3093 0: abc
3094    aBc
3095 0: aBc
3096\= Expect no match
3097    ABC
3098No match
3099    abC
3100No match
3101    aBC
3102No match
3103
3104/a(?i:b)*c/
3105    aBc
3106 0: aBc
3107    aBBc
3108 0: aBBc
3109\= Expect no match
3110    aBC
3111No match
3112    aBBC
3113No match
3114
3115/a(?=b(?i)c)\w\wd/
3116    abcd
3117 0: abcd
3118    abCd
3119 0: abCd
3120\= Expect no match
3121    aBCd
3122No match
3123    abcD
3124No match
3125
3126/(?s-i:more.*than).*million/i
3127    more than million
3128 0: more than million
3129    more than MILLION
3130 0: more than MILLION
3131    more \n than Million
3132 0: more \x0a than Million
3133\= Expect no match
3134    MORE THAN MILLION
3135No match
3136    more \n than \n million
3137No match
3138
3139/(?:(?s-i)more.*than).*million/i
3140    more than million
3141 0: more than million
3142    more than MILLION
3143 0: more than MILLION
3144    more \n than Million
3145 0: more \x0a than Million
3146\= Expect no match
3147    MORE THAN MILLION
3148No match
3149    more \n than \n million
3150No match
3151
3152/(?>a(?i)b+)+c/
3153    abc
3154 0: abc
3155    aBbc
3156 0: aBbc
3157    aBBc
3158 0: aBBc
3159\= Expect no match
3160    Abc
3161No match
3162    abAb
3163No match
3164    abbC
3165No match
3166
3167/(?=a(?i)b)\w\wc/
3168    abc
3169 0: abc
3170    aBc
3171 0: aBc
3172\= Expect no match
3173    Ab
3174No match
3175    abC
3176No match
3177    aBC
3178No match
3179
3180/(?<=a(?i)b)(\w\w)c/
3181    abxxc
3182 0: xxc
3183 1: xx
3184    aBxxc
3185 0: xxc
3186 1: xx
3187\= Expect no match
3188    Abxxc
3189No match
3190    ABxxc
3191No match
3192    abxxC
3193No match
3194
3195/(?:(a)|b)(?(1)A|B)/
3196    aA
3197 0: aA
3198 1: a
3199    bB
3200 0: bB
3201\= Expect no match
3202    aB
3203No match
3204    bA
3205No match
3206
3207/^(a)?(?(1)a|b)+$/
3208    aa
3209 0: aa
3210 1: a
3211    b
3212 0: b
3213    bb
3214 0: bb
3215\= Expect no match
3216    ab
3217No match
3218
3219# Perl gets this next one wrong if the pattern ends with $; in that case it
3220# fails to match "12".
3221
3222/^(?(?=abc)\w{3}:|\d\d)/
3223    abc:
3224 0: abc:
3225    12
3226 0: 12
3227    123
3228 0: 12
3229\= Expect no match
3230    xyz
3231No match
3232
3233/^(?(?!abc)\d\d|\w{3}:)$/
3234    abc:
3235 0: abc:
3236    12
3237 0: 12
3238\= Expect no match
3239    123
3240No match
3241    xyz
3242No match
3243
3244/(?(?<=foo)bar|cat)/
3245    foobar
3246 0: bar
3247    cat
3248 0: cat
3249    fcat
3250 0: cat
3251    focat
3252 0: cat
3253\= Expect no match
3254    foocat
3255No match
3256
3257/(?(?<!foo)cat|bar)/
3258    foobar
3259 0: bar
3260    cat
3261 0: cat
3262    fcat
3263 0: cat
3264    focat
3265 0: cat
3266\= Expect no match
3267    foocat
3268No match
3269
3270/( \( )? [^()]+ (?(1) \) |) /x
3271    abcd
3272 0: abcd
3273    (abcd)
3274 0: (abcd)
3275 1: (
3276    the quick (abcd) fox
3277 0: the quick
3278    (abcd
3279 0: abcd
3280
3281/( \( )? [^()]+ (?(1) \) ) /x
3282    abcd
3283 0: abcd
3284    (abcd)
3285 0: (abcd)
3286 1: (
3287    the quick (abcd) fox
3288 0: the quick
3289    (abcd
3290 0: abcd
3291
3292/^(?(2)a|(1)(2))+$/
3293    12
3294 0: 12
3295 1: 1
3296 2: 2
3297    12a
3298 0: 12a
3299 1: 1
3300 2: 2
3301    12aa
3302 0: 12aa
3303 1: 1
3304 2: 2
3305\= Expect no match
3306    1234
3307No match
3308
3309/((?i)blah)\s+\1/
3310    blah blah
3311 0: blah blah
3312 1: blah
3313    BLAH BLAH
3314 0: BLAH BLAH
3315 1: BLAH
3316    Blah Blah
3317 0: Blah Blah
3318 1: Blah
3319    blaH blaH
3320 0: blaH blaH
3321 1: blaH
3322\= Expect no match
3323    blah BLAH
3324No match
3325    Blah blah
3326No match
3327    blaH blah
3328No match
3329
3330/((?i)blah)\s+(?i:\1)/
3331    blah blah
3332 0: blah blah
3333 1: blah
3334    BLAH BLAH
3335 0: BLAH BLAH
3336 1: BLAH
3337    Blah Blah
3338 0: Blah Blah
3339 1: Blah
3340    blaH blaH
3341 0: blaH blaH
3342 1: blaH
3343    blah BLAH
3344 0: blah BLAH
3345 1: blah
3346    Blah blah
3347 0: Blah blah
3348 1: Blah
3349    blaH blah
3350 0: blaH blah
3351 1: blaH
3352
3353/((?i)blah)\s+(?m)A(?i:\1)/
3354    blah ABLAH
3355 0: blah ABLAH
3356 1: blah
3357\= Expect no match
3358    blah aBLAH
3359No match
3360
3361/(?>a*)*/
3362    a
3363 0: a
3364    aa
3365 0: aa
3366    aaaa
3367 0: aaaa
3368
3369/(abc|)+/
3370    abc
3371 0: abc
3372 1:
3373    abcabc
3374 0: abcabc
3375 1:
3376    abcabcabc
3377 0: abcabcabc
3378 1:
3379    xyz
3380 0:
3381 1:
3382
3383/([a]*)*/
3384    a
3385 0: a
3386 1:
3387    aaaaa
3388 0: aaaaa
3389 1:
3390
3391/([ab]*)*/
3392    a
3393 0: a
3394 1:
3395    b
3396 0: b
3397 1:
3398    ababab
3399 0: ababab
3400 1:
3401    aaaabcde
3402 0: aaaab
3403 1:
3404    bbbb
3405 0: bbbb
3406 1:
3407
3408/([^a]*)*/
3409    b
3410 0: b
3411 1:
3412    bbbb
3413 0: bbbb
3414 1:
3415    aaa
3416 0:
3417 1:
3418
3419/([^ab]*)*/
3420    cccc
3421 0: cccc
3422 1:
3423    abab
3424 0:
3425 1:
3426
3427/([a]*?)*/
3428    a
3429 0:
3430 1:
3431    aaaa
3432 0:
3433 1:
3434
3435/([ab]*?)*/
3436    a
3437 0:
3438 1:
3439    b
3440 0:
3441 1:
3442    abab
3443 0:
3444 1:
3445    baba
3446 0:
3447 1:
3448
3449/([^a]*?)*/
3450    b
3451 0:
3452 1:
3453    bbbb
3454 0:
3455 1:
3456    aaa
3457 0:
3458 1:
3459
3460/([^ab]*?)*/
3461    c
3462 0:
3463 1:
3464    cccc
3465 0:
3466 1:
3467    baba
3468 0:
3469 1:
3470
3471/(?>a*)*/
3472    a
3473 0: a
3474    aaabcde
3475 0: aaa
3476
3477/((?>a*))*/
3478    aaaaa
3479 0: aaaaa
3480 1:
3481    aabbaa
3482 0: aa
3483 1:
3484
3485/((?>a*?))*/
3486    aaaaa
3487 0:
3488 1:
3489    aabbaa
3490 0:
3491 1:
3492
3493/(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /x
3494    12-sep-98
3495 0: 12-sep-98
3496    12-09-98
3497 0: 12-09-98
3498\= Expect no match
3499    sep-12-98
3500No match
3501
3502/(?<=(foo))bar\1/
3503    foobarfoo
3504 0: barfoo
3505 1: foo
3506    foobarfootling
3507 0: barfoo
3508 1: foo
3509\= Expect no match
3510    foobar
3511No match
3512    barfoo
3513No match
3514
3515/(?i:saturday|sunday)/
3516    saturday
3517 0: saturday
3518    sunday
3519 0: sunday
3520    Saturday
3521 0: Saturday
3522    Sunday
3523 0: Sunday
3524    SATURDAY
3525 0: SATURDAY
3526    SUNDAY
3527 0: SUNDAY
3528    SunDay
3529 0: SunDay
3530
3531/(a(?i)bc|BB)x/
3532    abcx
3533 0: abcx
3534 1: abc
3535    aBCx
3536 0: aBCx
3537 1: aBC
3538    bbx
3539 0: bbx
3540 1: bb
3541    BBx
3542 0: BBx
3543 1: BB
3544\= Expect no match
3545    abcX
3546No match
3547    aBCX
3548No match
3549    bbX
3550No match
3551    BBX
3552No match
3553
3554/^([ab](?i)[cd]|[ef])/
3555    ac
3556 0: ac
3557 1: ac
3558    aC
3559 0: aC
3560 1: aC
3561    bD
3562 0: bD
3563 1: bD
3564    elephant
3565 0: e
3566 1: e
3567    Europe
3568 0: E
3569 1: E
3570    frog
3571 0: f
3572 1: f
3573    France
3574 0: F
3575 1: F
3576\= Expect no match
3577    Africa
3578No match
3579
3580/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
3581    ab
3582 0: ab
3583 1: ab
3584    aBd
3585 0: aBd
3586 1: aBd
3587    xy
3588 0: xy
3589 1: xy
3590    xY
3591 0: xY
3592 1: xY
3593    zebra
3594 0: z
3595 1: z
3596    Zambesi
3597 0: Z
3598 1: Z
3599\= Expect no match
3600    aCD
3601No match
3602    XY
3603No match
3604
3605/(?<=foo\n)^bar/m
3606    foo\nbar
3607 0: bar
3608\= Expect no match
3609    bar
3610No match
3611    baz\nbar
3612No match
3613
3614/(?<=(?<!foo)bar)baz/
3615    barbaz
3616 0: baz
3617    barbarbaz
3618 0: baz
3619    koobarbaz
3620 0: baz
3621\= Expect no match
3622    baz
3623No match
3624    foobarbaz
3625No match
3626
3627# The cases of aaaa and aaaaaa are missed out below because Perl does things
3628# differently. We know that odd, and maybe incorrect, things happen with
3629# recursive references in Perl, as far as 5.11.3 - see some stuff in test #2.
3630
3631/^(a\1?){4}$/
3632    aaaaa
3633 0: aaaaa
3634 1: a
3635    aaaaaaa
3636 0: aaaaaaa
3637 1: a
3638    aaaaaaaaaa
3639 0: aaaaaaaaaa
3640 1: aaaa
3641\= Expect no match
3642    a
3643No match
3644    aa
3645No match
3646    aaa
3647No match
3648    aaaaaaaa
3649No match
3650    aaaaaaaaa
3651No match
3652    aaaaaaaaaaa
3653No match
3654    aaaaaaaaaaaa
3655No match
3656    aaaaaaaaaaaaa
3657No match
3658    aaaaaaaaaaaaaa
3659No match
3660    aaaaaaaaaaaaaaa
3661No match
3662    aaaaaaaaaaaaaaaa
3663No match
3664
3665/^(a\1?)(a\1?)(a\2?)(a\3?)$/
3666    aaaa
3667 0: aaaa
3668 1: a
3669 2: a
3670 3: a
3671 4: a
3672    aaaaa
3673 0: aaaaa
3674 1: a
3675 2: aa
3676 3: a
3677 4: a
3678    aaaaaa
3679 0: aaaaaa
3680 1: a
3681 2: aa
3682 3: a
3683 4: aa
3684    aaaaaaa
3685 0: aaaaaaa
3686 1: a
3687 2: aa
3688 3: aaa
3689 4: a
3690    aaaaaaaaaa
3691 0: aaaaaaaaaa
3692 1: a
3693 2: aa
3694 3: aaa
3695 4: aaaa
3696\= Expect no match
3697    a
3698No match
3699    aa
3700No match
3701    aaa
3702No match
3703    aaaaaaaa
3704No match
3705    aaaaaaaaa
3706No match
3707    aaaaaaaaaaa
3708No match
3709    aaaaaaaaaaaa
3710No match
3711    aaaaaaaaaaaaa
3712No match
3713    aaaaaaaaaaaaaa
3714No match
3715    aaaaaaaaaaaaaaa
3716No match
3717    aaaaaaaaaaaaaaaa
3718No match
3719
3720# The following tests are taken from the Perl 5.005 test suite; some of them
3721# are compatible with 5.004, but I'd rather not have to sort them out.
3722
3723/abc/
3724    abc
3725 0: abc
3726    xabcy
3727 0: abc
3728    ababc
3729 0: abc
3730\= Expect no match
3731    xbc
3732No match
3733    axc
3734No match
3735    abx
3736No match
3737
3738/ab*c/
3739    abc
3740 0: abc
3741
3742/ab*bc/
3743    abc
3744 0: abc
3745    abbc
3746 0: abbc
3747    abbbbc
3748 0: abbbbc
3749
3750/.{1}/
3751    abbbbc
3752 0: a
3753
3754/.{3,4}/
3755    abbbbc
3756 0: abbb
3757
3758/ab{0,}bc/
3759    abbbbc
3760 0: abbbbc
3761
3762/ab+bc/
3763    abbc
3764 0: abbc
3765\= Expect no match
3766    abc
3767No match
3768    abq
3769No match
3770
3771/ab{1,}bc/
3772
3773/ab+bc/
3774    abbbbc
3775 0: abbbbc
3776
3777/ab{1,}bc/
3778    abbbbc
3779 0: abbbbc
3780
3781/ab{1,3}bc/
3782    abbbbc
3783 0: abbbbc
3784
3785/ab{3,4}bc/
3786    abbbbc
3787 0: abbbbc
3788
3789/ab{4,5}bc/
3790\= Expect no match
3791    abq
3792No match
3793    abbbbc
3794No match
3795
3796/ab?bc/
3797    abbc
3798 0: abbc
3799    abc
3800 0: abc
3801
3802/ab{0,1}bc/
3803    abc
3804 0: abc
3805
3806/ab?bc/
3807
3808/ab?c/
3809    abc
3810 0: abc
3811
3812/ab{0,1}c/
3813    abc
3814 0: abc
3815
3816/^abc$/
3817    abc
3818 0: abc
3819\= Expect no match
3820    abbbbc
3821No match
3822    abcc
3823No match
3824
3825/^abc/
3826    abcc
3827 0: abc
3828
3829/^abc$/
3830
3831/abc$/
3832    aabc
3833 0: abc
3834\= Expect no match
3835    aabcd
3836No match
3837
3838/^/
3839    abc
3840 0:
3841
3842/$/
3843    abc
3844 0:
3845
3846/a.c/
3847    abc
3848 0: abc
3849    axc
3850 0: axc
3851
3852/a.*c/
3853    axyzc
3854 0: axyzc
3855
3856/a[bc]d/
3857    abd
3858 0: abd
3859\= Expect no match
3860    axyzd
3861No match
3862    abc
3863No match
3864
3865/a[b-d]e/
3866    ace
3867 0: ace
3868
3869/a[b-d]/
3870    aac
3871 0: ac
3872
3873/a[-b]/
3874    a-
3875 0: a-
3876
3877/a[b-]/
3878    a-
3879 0: a-
3880
3881/a]/
3882    a]
3883 0: a]
3884
3885/a[]]b/
3886    a]b
3887 0: a]b
3888
3889/a[^bc]d/
3890    aed
3891 0: aed
3892\= Expect no match
3893    abd
3894No match
3895    abd
3896No match
3897
3898/a[^-b]c/
3899    adc
3900 0: adc
3901
3902/a[^]b]c/
3903    adc
3904 0: adc
3905    a-c
3906 0: a-c
3907\= Expect no match
3908    a]c
3909No match
3910
3911/\ba\b/
3912    a-
3913 0: a
3914    -a
3915 0: a
3916    -a-
3917 0: a
3918
3919/\by\b/
3920\= Expect no match
3921    xy
3922No match
3923    yz
3924No match
3925    xyz
3926No match
3927
3928/\Ba\B/
3929\= Expect no match
3930    a-
3931No match
3932    -a
3933No match
3934    -a-
3935No match
3936
3937/\By\b/
3938    xy
3939 0: y
3940
3941/\by\B/
3942    yz
3943 0: y
3944
3945/\By\B/
3946    xyz
3947 0: y
3948
3949/\w/
3950    a
3951 0: a
3952
3953/\W/
3954    -
3955 0: -
3956\= Expect no match
3957    a
3958No match
3959
3960/a\sb/
3961    a b
3962 0: a b
3963
3964/a\Sb/
3965    a-b
3966 0: a-b
3967\= Expect no match
3968    a b
3969No match
3970
3971/\d/
3972    1
3973 0: 1
3974
3975/\D/
3976    -
3977 0: -
3978\= Expect no match
3979    1
3980No match
3981
3982/[\w]/
3983    a
3984 0: a
3985
3986/[\W]/
3987    -
3988 0: -
3989\= Expect no match
3990    a
3991No match
3992
3993/a[\s]b/
3994    a b
3995 0: a b
3996
3997/a[\S]b/
3998    a-b
3999 0: a-b
4000\= Expect no match
4001    a b
4002No match
4003
4004/[\d]/
4005    1
4006 0: 1
4007
4008/[\D]/
4009    -
4010 0: -
4011\= Expect no match
4012    1
4013No match
4014
4015/ab|cd/
4016    abc
4017 0: ab
4018    abcd
4019 0: ab
4020
4021/()ef/
4022    def
4023 0: ef
4024 1:
4025
4026/$b/
4027
4028/a\(b/
4029    a(b
4030 0: a(b
4031
4032/a\(*b/
4033    ab
4034 0: ab
4035    a((b
4036 0: a((b
4037
4038/a\\b/
4039    a\\b
4040 0: a\b
4041
4042/((a))/
4043    abc
4044 0: a
4045 1: a
4046 2: a
4047
4048/(a)b(c)/
4049    abc
4050 0: abc
4051 1: a
4052 2: c
4053
4054/a+b+c/
4055    aabbabc
4056 0: abc
4057
4058/a{1,}b{1,}c/
4059    aabbabc
4060 0: abc
4061
4062/a.+?c/
4063    abcabc
4064 0: abc
4065
4066/(a+|b)*/
4067    ab
4068 0: ab
4069 1: b
4070
4071/(a+|b){0,}/
4072    ab
4073 0: ab
4074 1: b
4075
4076/(a+|b)+/
4077    ab
4078 0: ab
4079 1: b
4080
4081/(a+|b){1,}/
4082    ab
4083 0: ab
4084 1: b
4085
4086/(a+|b)?/
4087    ab
4088 0: a
4089 1: a
4090
4091/(a+|b){0,1}/
4092    ab
4093 0: a
4094 1: a
4095
4096/[^ab]*/
4097    cde
4098 0: cde
4099
4100/abc/
4101\= Expect no match
4102    b
4103No match
4104
4105/a*/
4106    \
4107 0:
4108
4109/([abc])*d/
4110    abbbcd
4111 0: abbbcd
4112 1: c
4113
4114/([abc])*bcd/
4115    abcd
4116 0: abcd
4117 1: a
4118
4119/a|b|c|d|e/
4120    e
4121 0: e
4122
4123/(a|b|c|d|e)f/
4124    ef
4125 0: ef
4126 1: e
4127
4128/abcd*efg/
4129    abcdefg
4130 0: abcdefg
4131
4132/ab*/
4133    xabyabbbz
4134 0: ab
4135    xayabbbz
4136 0: a
4137
4138/(ab|cd)e/
4139    abcde
4140 0: cde
4141 1: cd
4142
4143/[abhgefdc]ij/
4144    hij
4145 0: hij
4146
4147/^(ab|cd)e/
4148
4149/(abc|)ef/
4150    abcdef
4151 0: ef
4152 1:
4153
4154/(a|b)c*d/
4155    abcd
4156 0: bcd
4157 1: b
4158
4159/(ab|ab*)bc/
4160    abc
4161 0: abc
4162 1: a
4163
4164/a([bc]*)c*/
4165    abc
4166 0: abc
4167 1: bc
4168
4169/a([bc]*)(c*d)/
4170    abcd
4171 0: abcd
4172 1: bc
4173 2: d
4174
4175/a([bc]+)(c*d)/
4176    abcd
4177 0: abcd
4178 1: bc
4179 2: d
4180
4181/a([bc]*)(c+d)/
4182    abcd
4183 0: abcd
4184 1: b
4185 2: cd
4186
4187/a[bcd]*dcdcde/
4188    adcdcde
4189 0: adcdcde
4190
4191/a[bcd]+dcdcde/
4192\= Expect no match
4193    abcde
4194No match
4195    adcdcde
4196No match
4197
4198/(ab|a)b*c/
4199    abc
4200 0: abc
4201 1: ab
4202
4203/((a)(b)c)(d)/
4204    abcd
4205 0: abcd
4206 1: abc
4207 2: a
4208 3: b
4209 4: d
4210
4211/[a-zA-Z_][a-zA-Z0-9_]*/
4212    alpha
4213 0: alpha
4214
4215/^a(bc+|b[eh])g|.h$/
4216    abh
4217 0: bh
4218
4219/(bc+d$|ef*g.|h?i(j|k))/
4220    effgz
4221 0: effgz
4222 1: effgz
4223    ij
4224 0: ij
4225 1: ij
4226 2: j
4227    reffgz
4228 0: effgz
4229 1: effgz
4230\= Expect no match
4231    effg
4232No match
4233    bcdd
4234No match
4235
4236/((((((((((a))))))))))/
4237    a
4238 0: a
4239 1: a
4240 2: a
4241 3: a
4242 4: a
4243 5: a
4244 6: a
4245 7: a
4246 8: a
4247 9: a
424810: a
4249
4250/((((((((((a))))))))))\10/
4251    aa
4252 0: aa
4253 1: a
4254 2: a
4255 3: a
4256 4: a
4257 5: a
4258 6: a
4259 7: a
4260 8: a
4261 9: a
426210: a
4263
4264/(((((((((a)))))))))/
4265    a
4266 0: a
4267 1: a
4268 2: a
4269 3: a
4270 4: a
4271 5: a
4272 6: a
4273 7: a
4274 8: a
4275 9: a
4276
4277/multiple words of text/
4278\= Expect no match
4279    aa
4280No match
4281    uh-uh
4282No match
4283
4284/multiple words/
4285    multiple words, yeah
4286 0: multiple words
4287
4288/(.*)c(.*)/
4289    abcde
4290 0: abcde
4291 1: ab
4292 2: de
4293
4294/\((.*), (.*)\)/
4295    (a, b)
4296 0: (a, b)
4297 1: a
4298 2: b
4299
4300/[k]/
4301
4302/abcd/
4303    abcd
4304 0: abcd
4305
4306/a(bc)d/
4307    abcd
4308 0: abcd
4309 1: bc
4310
4311/a[-]?c/
4312    ac
4313 0: ac
4314
4315/(abc)\1/
4316    abcabc
4317 0: abcabc
4318 1: abc
4319
4320/([a-c]*)\1/
4321    abcabc
4322 0: abcabc
4323 1: abc
4324
4325/(a)|\1/
4326    a
4327 0: a
4328 1: a
4329    ab
4330 0: a
4331 1: a
4332\= Expect no match
4333    x
4334No match
4335
4336/(([a-c])b*?\2)*/
4337    ababbbcbc
4338 0: ababb
4339 1: bb
4340 2: b
4341
4342/(([a-c])b*?\2){3}/
4343    ababbbcbc
4344 0: ababbbcbc
4345 1: cbc
4346 2: c
4347
4348/((\3|b)\2(a)x)+/
4349    aaaxabaxbaaxbbax
4350 0: bbax
4351 1: bbax
4352 2: b
4353 3: a
4354
4355/((\3|b)\2(a)){2,}/
4356    bbaababbabaaaaabbaaaabba
4357 0: bbaaaabba
4358 1: bba
4359 2: b
4360 3: a
4361
4362/abc/i
4363    ABC
4364 0: ABC
4365    XABCY
4366 0: ABC
4367    ABABC
4368 0: ABC
4369\= Expect no match
4370    aaxabxbaxbbx
4371No match
4372    XBC
4373No match
4374    AXC
4375No match
4376    ABX
4377No match
4378
4379/ab*c/i
4380    ABC
4381 0: ABC
4382
4383/ab*bc/i
4384    ABC
4385 0: ABC
4386    ABBC
4387 0: ABBC
4388
4389/ab*?bc/i
4390    ABBBBC
4391 0: ABBBBC
4392
4393/ab{0,}?bc/i
4394    ABBBBC
4395 0: ABBBBC
4396
4397/ab+?bc/i
4398    ABBC
4399 0: ABBC
4400
4401/ab+bc/i
4402\= Expect no match
4403    ABC
4404No match
4405    ABQ
4406No match
4407
4408/ab{1,}bc/i
4409
4410/ab+bc/i
4411    ABBBBC
4412 0: ABBBBC
4413
4414/ab{1,}?bc/i
4415    ABBBBC
4416 0: ABBBBC
4417
4418/ab{1,3}?bc/i
4419    ABBBBC
4420 0: ABBBBC
4421
4422/ab{3,4}?bc/i
4423    ABBBBC
4424 0: ABBBBC
4425
4426/ab{4,5}?bc/i
4427\= Expect no match
4428    ABQ
4429No match
4430    ABBBBC
4431No match
4432
4433/ab??bc/i
4434    ABBC
4435 0: ABBC
4436    ABC
4437 0: ABC
4438
4439/ab{0,1}?bc/i
4440    ABC
4441 0: ABC
4442
4443/ab??bc/i
4444
4445/ab??c/i
4446    ABC
4447 0: ABC
4448
4449/ab{0,1}?c/i
4450    ABC
4451 0: ABC
4452
4453/^abc$/i
4454    ABC
4455 0: ABC
4456\= Expect no match
4457    ABBBBC
4458No match
4459    ABCC
4460No match
4461
4462/^abc/i
4463    ABCC
4464 0: ABC
4465
4466/^abc$/i
4467
4468/abc$/i
4469    AABC
4470 0: ABC
4471
4472/^/i
4473    ABC
4474 0:
4475
4476/$/i
4477    ABC
4478 0:
4479
4480/a.c/i
4481    ABC
4482 0: ABC
4483    AXC
4484 0: AXC
4485
4486/a.*?c/i
4487    AXYZC
4488 0: AXYZC
4489
4490/a.*c/i
4491    AABC
4492 0: AABC
4493\= Expect no match
4494    AXYZD
4495No match
4496
4497/a[bc]d/i
4498    ABD
4499 0: ABD
4500
4501/a[b-d]e/i
4502    ACE
4503 0: ACE
4504\= Expect no match
4505    ABC
4506No match
4507    ABD
4508No match
4509
4510/a[b-d]/i
4511    AAC
4512 0: AC
4513
4514/a[-b]/i
4515    A-
4516 0: A-
4517
4518/a[b-]/i
4519    A-
4520 0: A-
4521
4522/a]/i
4523    A]
4524 0: A]
4525
4526/a[]]b/i
4527    A]B
4528 0: A]B
4529
4530/a[^bc]d/i
4531    AED
4532 0: AED
4533
4534/a[^-b]c/i
4535    ADC
4536 0: ADC
4537\= Expect no match
4538    ABD
4539No match
4540    A-C
4541No match
4542
4543/a[^]b]c/i
4544    ADC
4545 0: ADC
4546
4547/ab|cd/i
4548    ABC
4549 0: AB
4550    ABCD
4551 0: AB
4552
4553/()ef/i
4554    DEF
4555 0: EF
4556 1:
4557
4558/$b/i
4559\= Expect no match
4560    A]C
4561No match
4562    B
4563No match
4564
4565/a\(b/i
4566    A(B
4567 0: A(B
4568
4569/a\(*b/i
4570    AB
4571 0: AB
4572    A((B
4573 0: A((B
4574
4575/a\\b/i
4576    A\\b
4577 0: A\b
4578    a\\B
4579 0: a\B
4580
4581/((a))/i
4582    ABC
4583 0: A
4584 1: A
4585 2: A
4586
4587/(a)b(c)/i
4588    ABC
4589 0: ABC
4590 1: A
4591 2: C
4592
4593/a+b+c/i
4594    AABBABC
4595 0: ABC
4596
4597/a{1,}b{1,}c/i
4598    AABBABC
4599 0: ABC
4600
4601/a.+?c/i
4602    ABCABC
4603 0: ABC
4604
4605/a.*?c/i
4606    ABCABC
4607 0: ABC
4608
4609/a.{0,5}?c/i
4610    ABCABC
4611 0: ABC
4612
4613/(a+|b)*/i
4614    AB
4615 0: AB
4616 1: B
4617
4618/(a+|b){0,}/i
4619    AB
4620 0: AB
4621 1: B
4622
4623/(a+|b)+/i
4624    AB
4625 0: AB
4626 1: B
4627
4628/(a+|b){1,}/i
4629    AB
4630 0: AB
4631 1: B
4632
4633/(a+|b)?/i
4634    AB
4635 0: A
4636 1: A
4637
4638/(a+|b){0,1}/i
4639    AB
4640 0: A
4641 1: A
4642
4643/(a+|b){0,1}?/i
4644    AB
4645 0:
4646
4647/[^ab]*/i
4648    CDE
4649 0: CDE
4650
4651/([abc])*d/i
4652    ABBBCD
4653 0: ABBBCD
4654 1: C
4655
4656/([abc])*bcd/i
4657    ABCD
4658 0: ABCD
4659 1: A
4660
4661/a|b|c|d|e/i
4662    E
4663 0: E
4664
4665/(a|b|c|d|e)f/i
4666    EF
4667 0: EF
4668 1: E
4669
4670/abcd*efg/i
4671    ABCDEFG
4672 0: ABCDEFG
4673
4674/ab*/i
4675    XABYABBBZ
4676 0: AB
4677    XAYABBBZ
4678 0: A
4679
4680/(ab|cd)e/i
4681    ABCDE
4682 0: CDE
4683 1: CD
4684
4685/[abhgefdc]ij/i
4686    HIJ
4687 0: HIJ
4688
4689/^(ab|cd)e/i
4690\= Expect no match
4691    ABCDE
4692No match
4693
4694/(abc|)ef/i
4695    ABCDEF
4696 0: EF
4697 1:
4698
4699/(a|b)c*d/i
4700    ABCD
4701 0: BCD
4702 1: B
4703
4704/(ab|ab*)bc/i
4705    ABC
4706 0: ABC
4707 1: A
4708
4709/a([bc]*)c*/i
4710    ABC
4711 0: ABC
4712 1: BC
4713
4714/a([bc]*)(c*d)/i
4715    ABCD
4716 0: ABCD
4717 1: BC
4718 2: D
4719
4720/a([bc]+)(c*d)/i
4721    ABCD
4722 0: ABCD
4723 1: BC
4724 2: D
4725
4726/a([bc]*)(c+d)/i
4727    ABCD
4728 0: ABCD
4729 1: B
4730 2: CD
4731
4732/a[bcd]*dcdcde/i
4733    ADCDCDE
4734 0: ADCDCDE
4735
4736/a[bcd]+dcdcde/i
4737
4738/(ab|a)b*c/i
4739    ABC
4740 0: ABC
4741 1: AB
4742
4743/((a)(b)c)(d)/i
4744    ABCD
4745 0: ABCD
4746 1: ABC
4747 2: A
4748 3: B
4749 4: D
4750
4751/[a-zA-Z_][a-zA-Z0-9_]*/i
4752    ALPHA
4753 0: ALPHA
4754
4755/^a(bc+|b[eh])g|.h$/i
4756    ABH
4757 0: BH
4758
4759/(bc+d$|ef*g.|h?i(j|k))/i
4760    EFFGZ
4761 0: EFFGZ
4762 1: EFFGZ
4763    IJ
4764 0: IJ
4765 1: IJ
4766 2: J
4767    REFFGZ
4768 0: EFFGZ
4769 1: EFFGZ
4770\= Expect no match
4771    ADCDCDE
4772No match
4773    EFFG
4774No match
4775    BCDD
4776No match
4777
4778/((((((((((a))))))))))/i
4779    A
4780 0: A
4781 1: A
4782 2: A
4783 3: A
4784 4: A
4785 5: A
4786 6: A
4787 7: A
4788 8: A
4789 9: A
479010: A
4791
4792/((((((((((a))))))))))\10/i
4793    AA
4794 0: AA
4795 1: A
4796 2: A
4797 3: A
4798 4: A
4799 5: A
4800 6: A
4801 7: A
4802 8: A
4803 9: A
480410: A
4805
4806/(((((((((a)))))))))/i
4807    A
4808 0: A
4809 1: A
4810 2: A
4811 3: A
4812 4: A
4813 5: A
4814 6: A
4815 7: A
4816 8: A
4817 9: A
4818
4819/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
4820    A
4821 0: A
4822 1: A
4823
4824/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
4825    C
4826 0: C
4827 1: C
4828
4829/multiple words of text/i
4830\= Expect no match
4831    AA
4832No match
4833    UH-UH
4834No match
4835
4836/multiple words/i
4837    MULTIPLE WORDS, YEAH
4838 0: MULTIPLE WORDS
4839
4840/(.*)c(.*)/i
4841    ABCDE
4842 0: ABCDE
4843 1: AB
4844 2: DE
4845
4846/\((.*), (.*)\)/i
4847    (A, B)
4848 0: (A, B)
4849 1: A
4850 2: B
4851
4852/[k]/i
4853
4854/abcd/i
4855    ABCD
4856 0: ABCD
4857
4858/a(bc)d/i
4859    ABCD
4860 0: ABCD
4861 1: BC
4862
4863/a[-]?c/i
4864    AC
4865 0: AC
4866
4867/(abc)\1/i
4868    ABCABC
4869 0: ABCABC
4870 1: ABC
4871
4872/([a-c]*)\1/i
4873    ABCABC
4874 0: ABCABC
4875 1: ABC
4876
4877/a(?!b)./
4878    abad
4879 0: ad
4880
4881/a(?=d)./
4882    abad
4883 0: ad
4884
4885/a(?=c|d)./
4886    abad
4887 0: ad
4888
4889/a(?:b|c|d)(.)/
4890    ace
4891 0: ace
4892 1: e
4893
4894/a(?:b|c|d)*(.)/
4895    ace
4896 0: ace
4897 1: e
4898
4899/a(?:b|c|d)+?(.)/
4900    ace
4901 0: ace
4902 1: e
4903    acdbcdbe
4904 0: acd
4905 1: d
4906
4907/a(?:b|c|d)+(.)/
4908    acdbcdbe
4909 0: acdbcdbe
4910 1: e
4911
4912/a(?:b|c|d){2}(.)/
4913    acdbcdbe
4914 0: acdb
4915 1: b
4916
4917/a(?:b|c|d){4,5}(.)/
4918    acdbcdbe
4919 0: acdbcdb
4920 1: b
4921
4922/a(?:b|c|d){4,5}?(.)/
4923    acdbcdbe
4924 0: acdbcd
4925 1: d
4926
4927/((foo)|(bar))*/
4928    foobar
4929 0: foobar
4930 1: bar
4931 2: foo
4932 3: bar
4933
4934/a(?:b|c|d){6,7}(.)/
4935    acdbcdbe
4936 0: acdbcdbe
4937 1: e
4938
4939/a(?:b|c|d){6,7}?(.)/
4940    acdbcdbe
4941 0: acdbcdbe
4942 1: e
4943
4944/a(?:b|c|d){5,6}(.)/
4945    acdbcdbe
4946 0: acdbcdbe
4947 1: e
4948
4949/a(?:b|c|d){5,6}?(.)/
4950    acdbcdbe
4951 0: acdbcdb
4952 1: b
4953
4954/a(?:b|c|d){5,7}(.)/
4955    acdbcdbe
4956 0: acdbcdbe
4957 1: e
4958
4959/a(?:b|c|d){5,7}?(.)/
4960    acdbcdbe
4961 0: acdbcdb
4962 1: b
4963
4964/a(?:b|(c|e){1,2}?|d)+?(.)/
4965    ace
4966 0: ace
4967 1: c
4968 2: e
4969
4970/^(.+)?B/
4971    AB
4972 0: AB
4973 1: A
4974
4975/^([^a-z])|(\^)$/
4976    .
4977 0: .
4978 1: .
4979
4980/^[<>]&/
4981    <&OUT
4982 0: <&
4983
4984/^(a\1?){4}$/
4985    aaaaaaaaaa
4986 0: aaaaaaaaaa
4987 1: aaaa
4988\= Expect no match
4989    AB
4990No match
4991    aaaaaaaaa
4992No match
4993    aaaaaaaaaaa
4994No match
4995
4996/^(a(?(1)\1)){4}$/
4997    aaaaaaaaaa
4998 0: aaaaaaaaaa
4999 1: aaaa
5000\= Expect no match
5001    aaaaaaaaa
5002No match
5003    aaaaaaaaaaa
5004No match
5005
5006/(?:(f)(o)(o)|(b)(a)(r))*/
5007    foobar
5008 0: foobar
5009 1: f
5010 2: o
5011 3: o
5012 4: b
5013 5: a
5014 6: r
5015
5016/(?<=a)b/
5017    ab
5018 0: b
5019\= Expect no match
5020    cb
5021No match
5022    b
5023No match
5024
5025/(?<!c)b/
5026    ab
5027 0: b
5028    b
5029 0: b
5030    b
5031 0: b
5032
5033/(?:..)*a/
5034    aba
5035 0: aba
5036
5037/(?:..)*?a/
5038    aba
5039 0: a
5040
5041/^(?:b|a(?=(.)))*\1/
5042    abc
5043 0: ab
5044 1: b
5045
5046/^(){3,5}/
5047    abc
5048 0:
5049 1:
5050
5051/^(a+)*ax/
5052    aax
5053 0: aax
5054 1: a
5055
5056/^((a|b)+)*ax/
5057    aax
5058 0: aax
5059 1: a
5060 2: a
5061
5062/^((a|bc)+)*ax/
5063    aax
5064 0: aax
5065 1: a
5066 2: a
5067
5068/(a|x)*ab/
5069    cab
5070 0: ab
5071
5072/(a)*ab/
5073    cab
5074 0: ab
5075
5076/(?:(?i)a)b/
5077    ab
5078 0: ab
5079
5080/((?i)a)b/
5081    ab
5082 0: ab
5083 1: a
5084
5085/(?:(?i)a)b/
5086    Ab
5087 0: Ab
5088
5089/((?i)a)b/
5090    Ab
5091 0: Ab
5092 1: A
5093
5094/(?:(?i)a)b/
5095\= Expect no match
5096    cb
5097No match
5098    aB
5099No match
5100
5101/((?i)a)b/
5102
5103/(?i:a)b/
5104    ab
5105 0: ab
5106
5107/((?i:a))b/
5108    ab
5109 0: ab
5110 1: a
5111
5112/(?i:a)b/
5113    Ab
5114 0: Ab
5115
5116/((?i:a))b/
5117    Ab
5118 0: Ab
5119 1: A
5120
5121/(?i:a)b/
5122\= Expect no match
5123    aB
5124No match
5125    aB
5126No match
5127
5128/((?i:a))b/
5129
5130/(?:(?-i)a)b/i
5131    ab
5132 0: ab
5133
5134/((?-i)a)b/i
5135    ab
5136 0: ab
5137 1: a
5138
5139/(?:(?-i)a)b/i
5140    aB
5141 0: aB
5142
5143/((?-i)a)b/i
5144    aB
5145 0: aB
5146 1: a
5147
5148/(?:(?-i)a)b/i
5149    aB
5150 0: aB
5151\= Expect no match
5152    Ab
5153No match
5154    AB
5155No match
5156
5157/(?-i:a)b/i
5158    ab
5159 0: ab
5160
5161/((?-i:a))b/i
5162    ab
5163 0: ab
5164 1: a
5165
5166/(?-i:a)b/i
5167    aB
5168 0: aB
5169
5170/((?-i:a))b/i
5171    aB
5172 0: aB
5173 1: a
5174
5175/(?-i:a)b/i
5176\= Expect no match
5177    AB
5178No match
5179    Ab
5180No match
5181
5182/((?-i:a))b/i
5183
5184/(?-i:a)b/i
5185    aB
5186 0: aB
5187
5188/((?-i:a))b/i
5189    aB
5190 0: aB
5191 1: a
5192
5193/(?-i:a)b/i
5194\= Expect no match
5195    Ab
5196No match
5197    AB
5198No match
5199
5200/((?-i:a))b/i
5201
5202/((?-i:a.))b/i
5203\= Expect no match
5204    AB
5205No match
5206    a\nB
5207No match
5208
5209/((?s-i:a.))b/i
5210    a\nB
5211 0: a\x0aB
5212 1: a\x0a
5213
5214/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
5215    cabbbb
5216 0: cabbbb
5217
5218/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
5219    caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
5220 0: caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
5221
5222/(ab)\d\1/i
5223    Ab4ab
5224 0: Ab4ab
5225 1: Ab
5226    ab4Ab
5227 0: ab4Ab
5228 1: ab
5229
5230/foo\w*\d{4}baz/
5231    foobar1234baz
5232 0: foobar1234baz
5233
5234/x(~~)*(?:(?:F)?)?/
5235    x~~
5236 0: x~~
5237 1: ~~
5238
5239/^a(?#xxx){3}c/
5240    aaac
5241 0: aaac
5242
5243/^a (?#xxx) (?#yyy) {3}c/x
5244    aaac
5245 0: aaac
5246
5247/(?<![cd])b/
5248\= Expect no match
5249    B\nB
5250No match
5251    dbcb
5252No match
5253
5254/(?<![cd])[ab]/
5255    dbaacb
5256 0: a
5257
5258/(?<!(c|d))b/
5259
5260/(?<!(c|d))[ab]/
5261    dbaacb
5262 0: a
5263
5264/(?<!cd)[ab]/
5265    cdaccb
5266 0: b
5267
5268/^(?:a?b?)*$/
5269    \
5270 0:
5271    a
5272 0: a
5273    ab
5274 0: ab
5275    aaa
5276 0: aaa
5277\= Expect no match
5278    dbcb
5279No match
5280    a--
5281No match
5282    aa--
5283No match
5284
5285/((?s)^a(.))((?m)^b$)/
5286    a\nb\nc\n
5287 0: a\x0ab
5288 1: a\x0a
5289 2: \x0a
5290 3: b
5291
5292/((?m)^b$)/
5293    a\nb\nc\n
5294 0: b
5295 1: b
5296
5297/(?m)^b/
5298    a\nb\n
5299 0: b
5300
5301/(?m)^(b)/
5302    a\nb\n
5303 0: b
5304 1: b
5305
5306/((?m)^b)/
5307    a\nb\n
5308 0: b
5309 1: b
5310
5311/\n((?m)^b)/
5312    a\nb\n
5313 0: \x0ab
5314 1: b
5315
5316/((?s).)c(?!.)/
5317    a\nb\nc\n
5318 0: \x0ac
5319 1: \x0a
5320    a\nb\nc\n
5321 0: \x0ac
5322 1: \x0a
5323
5324/((?s)b.)c(?!.)/
5325    a\nb\nc\n
5326 0: b\x0ac
5327 1: b\x0a
5328    a\nb\nc\n
5329 0: b\x0ac
5330 1: b\x0a
5331
5332/^b/
5333
5334/()^b/
5335\= Expect no match
5336    a\nb\nc\n
5337No match
5338    a\nb\nc\n
5339No match
5340
5341/((?m)^b)/
5342    a\nb\nc\n
5343 0: b
5344 1: b
5345
5346/(x)?(?(1)a|b)/
5347\= Expect no match
5348    a
5349No match
5350    a
5351No match
5352
5353/(x)?(?(1)b|a)/
5354    a
5355 0: a
5356
5357/()?(?(1)b|a)/
5358    a
5359 0: a
5360
5361/()(?(1)b|a)/
5362
5363/()?(?(1)a|b)/
5364    a
5365 0: a
5366 1:
5367
5368/^(\()?blah(?(1)(\)))$/
5369    (blah)
5370 0: (blah)
5371 1: (
5372 2: )
5373    blah
5374 0: blah
5375\= Expect no match
5376    a
5377No match
5378    blah)
5379No match
5380    (blah
5381No match
5382
5383/^(\(+)?blah(?(1)(\)))$/
5384    (blah)
5385 0: (blah)
5386 1: (
5387 2: )
5388    blah
5389 0: blah
5390\= Expect no match
5391    blah)
5392No match
5393    (blah
5394No match
5395
5396/(?(?!a)a|b)/
5397
5398/(?(?!a)b|a)/
5399    a
5400 0: a
5401
5402/(?(?=a)b|a)/
5403\= Expect no match
5404    a
5405No match
5406    a
5407No match
5408
5409/(?(?=a)a|b)/
5410    a
5411 0: a
5412
5413/(?=(a+?))(\1ab)/
5414    aaab
5415 0: aab
5416 1: a
5417 2: aab
5418
5419/^(?=(a+?))\1ab/
5420
5421/(\w+:)+/
5422    one:
5423 0: one:
5424 1: one:
5425
5426/$(?<=^(a))/
5427    a
5428 0:
5429 1: a
5430
5431/(?=(a+?))(\1ab)/
5432    aaab
5433 0: aab
5434 1: a
5435 2: aab
5436
5437/^(?=(a+?))\1ab/
5438\= Expect no match
5439    aaab
5440No match
5441    aaab
5442No match
5443
5444/([\w:]+::)?(\w+)$/
5445    abcd
5446 0: abcd
5447 1: <unset>
5448 2: abcd
5449    xy:z:::abcd
5450 0: xy:z:::abcd
5451 1: xy:z:::
5452 2: abcd
5453
5454/^[^bcd]*(c+)/
5455    aexycd
5456 0: aexyc
5457 1: c
5458
5459/(a*)b+/
5460    caab
5461 0: aab
5462 1: aa
5463
5464/([\w:]+::)?(\w+)$/
5465    abcd
5466 0: abcd
5467 1: <unset>
5468 2: abcd
5469    xy:z:::abcd
5470 0: xy:z:::abcd
5471 1: xy:z:::
5472 2: abcd
5473\= Expect no match
5474    abcd:
5475No match
5476    abcd:
5477No match
5478
5479/^[^bcd]*(c+)/
5480    aexycd
5481 0: aexyc
5482 1: c
5483
5484/(>a+)ab/
5485
5486/(?>a+)b/
5487    aaab
5488 0: aaab
5489
5490/([[:]+)/
5491    a:[b]:
5492 0: :[
5493 1: :[
5494
5495/([[=]+)/
5496    a=[b]=
5497 0: =[
5498 1: =[
5499
5500/([[.]+)/
5501    a.[b].
5502 0: .[
5503 1: .[
5504
5505/((?>a+)b)/
5506    aaab
5507 0: aaab
5508 1: aaab
5509
5510/(?>(a+))b/
5511    aaab
5512 0: aaab
5513 1: aaa
5514
5515/((?>[^()]+)|\([^()]*\))+/
5516    ((abc(ade)ufh()()x
5517 0: abc(ade)ufh()()x
5518 1: x
5519
5520/a\Z/
5521\= Expect no match
5522    aaab
5523No match
5524    a\nb\n
5525No match
5526
5527/b\Z/
5528    a\nb\n
5529 0: b
5530
5531/b\z/
5532
5533/b\Z/
5534    a\nb
5535 0: b
5536
5537/b\z/
5538    a\nb
5539 0: b
5540
5541/^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
5542    a
5543 0: a
5544 1:
5545    abc
5546 0: abc
5547 1:
5548    a-b
5549 0: a-b
5550 1:
5551    0-9
5552 0: 0-9
5553 1:
5554    a.b
5555 0: a.b
5556 1:
5557    5.6.7
5558 0: 5.6.7
5559 1:
5560    the.quick.brown.fox
5561 0: the.quick.brown.fox
5562 1:
5563    a100.b200.300c
5564 0: a100.b200.300c
5565 1:
5566    12-ab.1245
5567 0: 12-ab.1245
5568 1:
5569\= Expect no match
5570    \
5571No match
5572    .a
5573No match
5574    -a
5575No match
5576    a-
5577No match
5578    a.
5579No match
5580    a_b
5581No match
5582    a.-
5583No match
5584    a..
5585No match
5586    ab..bc
5587No match
5588    the.quick.brown.fox-
5589No match
5590    the.quick.brown.fox.
5591No match
5592    the.quick.brown.fox_
5593No match
5594    the.quick.brown.fox+
5595No match
5596
5597/(?>.*)(?<=(abcd|wxyz))/
5598    alphabetabcd
5599 0: alphabetabcd
5600 1: abcd
5601    endingwxyz
5602 0: endingwxyz
5603 1: wxyz
5604\= Expect no match
5605    a rather long string that doesn't end with one of them
5606No match
5607
5608/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
5609    word cat dog elephant mussel cow horse canary baboon snake shark otherword
5610 0: word cat dog elephant mussel cow horse canary baboon snake shark otherword
5611\= Expect no match
5612    word cat dog elephant mussel cow horse canary baboon snake shark
5613No match
5614
5615/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
5616\= Expect no match
5617    word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope
5618No match
5619
5620/(?<=\d{3}(?!999))foo/
5621    999foo
5622 0: foo
5623    123999foo
5624 0: foo
5625\= Expect no match
5626    123abcfoo
5627No match
5628
5629/(?<=(?!...999)\d{3})foo/
5630    999foo
5631 0: foo
5632    123999foo
5633 0: foo
5634\= Expect no match
5635    123abcfoo
5636No match
5637
5638/(?<=\d{3}(?!999)...)foo/
5639    123abcfoo
5640 0: foo
5641    123456foo
5642 0: foo
5643\= Expect no match
5644    123999foo
5645No match
5646
5647/(?<=\d{3}...)(?<!999)foo/
5648    123abcfoo
5649 0: foo
5650    123456foo
5651 0: foo
5652\= Expect no match
5653    123999foo
5654No match
5655
5656/<a[\s]+href[\s]*=[\s]*          # find <a href=
5657 ([\"\'])?                       # find single or double quote
5658 (?(1) (.*?)\1 | ([^\s]+))       # if quote found, match up to next matching
5659                                 # quote, otherwise match up to next space
5660/isx
5661    <a href=abcd xyz
5662 0: <a href=abcd
5663 1: <unset>
5664 2: <unset>
5665 3: abcd
5666    <a href=\"abcd xyz pqr\" cats
5667 0: <a href="abcd xyz pqr"
5668 1: "
5669 2: abcd xyz pqr
5670    <a href=\'abcd xyz pqr\' cats
5671 0: <a href='abcd xyz pqr'
5672 1: '
5673 2: abcd xyz pqr
5674
5675/<a\s+href\s*=\s*                # find <a href=
5676 (["'])?                         # find single or double quote
5677 (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
5678                                 # quote, otherwise match up to next space
5679/isx
5680    <a href=abcd xyz
5681 0: <a href=abcd
5682 1: <unset>
5683 2: <unset>
5684 3: abcd
5685    <a href=\"abcd xyz pqr\" cats
5686 0: <a href="abcd xyz pqr"
5687 1: "
5688 2: abcd xyz pqr
5689    <a href       =       \'abcd xyz pqr\' cats
5690 0: <a href       =       'abcd xyz pqr'
5691 1: '
5692 2: abcd xyz pqr
5693
5694/<a\s+href(?>\s*)=(?>\s*)        # find <a href=
5695 (["'])?                         # find single or double quote
5696 (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
5697                                 # quote, otherwise match up to next space
5698/isx
5699    <a href=abcd xyz
5700 0: <a href=abcd
5701 1: <unset>
5702 2: <unset>
5703 3: abcd
5704    <a href=\"abcd xyz pqr\" cats
5705 0: <a href="abcd xyz pqr"
5706 1: "
5707 2: abcd xyz pqr
5708    <a href       =       \'abcd xyz pqr\' cats
5709 0: <a href       =       'abcd xyz pqr'
5710 1: '
5711 2: abcd xyz pqr
5712
5713/((Z)+|A)*/
5714    ZABCDEFG
5715 0: ZA
5716 1: A
5717 2: Z
5718
5719/(Z()|A)*/
5720    ZABCDEFG
5721 0: ZA
5722 1: A
5723 2:
5724
5725/(Z(())|A)*/
5726    ZABCDEFG
5727 0: ZA
5728 1: A
5729 2:
5730 3:
5731
5732/((?>Z)+|A)*/
5733    ZABCDEFG
5734 0: ZA
5735 1: A
5736
5737/((?>)+|A)*/
5738    ZABCDEFG
5739 0:
5740 1:
5741
5742/a*/g
5743    abbab
5744 0: a
5745 0:
5746 0:
5747 0: a
5748 0:
5749 0:
5750
5751/[[:space:]]+/
5752    > \x09\x0a\x0c\x0d\x0b<
5753 0:  \x09\x0a\x0c\x0d\x0b
5754
5755/[[:blank:]]+/
5756    > \x09\x0a\x0c\x0d\x0b<
5757 0:  \x09
5758
5759/[\s]+/
5760    > \x09\x0a\x0c\x0d\x0b<
5761 0:  \x09\x0a\x0c\x0d\x0b
5762
5763/\s+/
5764    > \x09\x0a\x0c\x0d\x0b<
5765 0:  \x09\x0a\x0c\x0d\x0b
5766
5767/ab/x
5768    ab
5769 0: ab
5770
5771/(?!\A)x/m
5772    a\nxb\n
5773 0: x
5774
5775/(?!^)x/m
5776\= Expect no match
5777    a\nxb\n
5778No match
5779
5780/abc\Qabc\Eabc/
5781    abcabcabc
5782 0: abcabcabc
5783
5784/abc\Q(*+|\Eabc/
5785    abc(*+|abc
5786 0: abc(*+|abc
5787
5788/   abc\Q abc\Eabc/x
5789    abc abcabc
5790 0: abc abcabc
5791\= Expect no match
5792    abcabcabc
5793No match
5794
5795/abc#comment
5796    \Q#not comment
5797    literal\E/x
5798    abc#not comment\n    literal
5799 0: abc#not comment\x0a    literal
5800
5801/abc#comment
5802    \Q#not comment
5803    literal/x
5804    abc#not comment\n    literal
5805 0: abc#not comment\x0a    literal
5806
5807/abc#comment
5808    \Q#not comment
5809    literal\E #more comment
5810    /x
5811    abc#not comment\n    literal
5812 0: abc#not comment\x0a    literal
5813
5814/abc#comment
5815    \Q#not comment
5816    literal\E #more comment/x
5817    abc#not comment\n    literal
5818 0: abc#not comment\x0a    literal
5819
5820/\Qabc\$xyz\E/
5821    abc\\\$xyz
5822 0: abc\$xyz
5823
5824/\Qabc\E\$\Qxyz\E/
5825    abc\$xyz
5826 0: abc$xyz
5827
5828/\Gabc/
5829    abc
5830 0: abc
5831\= Expect no match
5832    xyzabc
5833No match
5834
5835/\Gabc./g
5836    abc1abc2xyzabc3
5837 0: abc1
5838 0: abc2
5839
5840/abc./g
5841    abc1abc2xyzabc3
5842 0: abc1
5843 0: abc2
5844 0: abc3
5845
5846/a(?x: b c )d/
5847    XabcdY
5848 0: abcd
5849\= Expect no match
5850    Xa b c d Y
5851No match
5852
5853/((?x)x y z | a b c)/
5854    XabcY
5855 0: abc
5856 1: abc
5857    AxyzB
5858 0: xyz
5859 1: xyz
5860
5861/(?i)AB(?-i)C/
5862    XabCY
5863 0: abC
5864\= Expect no match
5865    XabcY
5866No match
5867
5868/((?i)AB(?-i)C|D)E/
5869    abCE
5870 0: abCE
5871 1: abC
5872    DE
5873 0: DE
5874 1: D
5875\= Expect no match
5876    abcE
5877No match
5878    abCe
5879No match
5880    dE
5881No match
5882    De
5883No match
5884
5885/(.*)\d+\1/
5886    abc123abc
5887 0: abc123abc
5888 1: abc
5889    abc123bc
5890 0: bc123bc
5891 1: bc
5892
5893/(.*)\d+\1/s
5894    abc123abc
5895 0: abc123abc
5896 1: abc
5897    abc123bc
5898 0: bc123bc
5899 1: bc
5900
5901/((.*))\d+\1/
5902    abc123abc
5903 0: abc123abc
5904 1: abc
5905 2: abc
5906    abc123bc
5907 0: bc123bc
5908 1: bc
5909 2: bc
5910
5911# This tests for an IPv6 address in the form where it can have up to
5912# eight components, one and only one of which is empty. This must be
5913# an internal component.
5914
5915/^(?!:)                       # colon disallowed at start
5916  (?:                         # start of item
5917    (?: [0-9a-f]{1,4} |       # 1-4 hex digits or
5918    (?(1)0 | () ) )           # if null previously matched, fail; else null
5919    :                         # followed by colon
5920  ){1,7}                      # end item; 1-7 of them required
5921  [0-9a-f]{1,4} $             # final hex number at end of string
5922  (?(1)|.)                    # check that there was an empty component
5923  /ix
5924    a123::a123
5925 0: a123::a123
5926 1:
5927    a123:b342::abcd
5928 0: a123:b342::abcd
5929 1:
5930    a123:b342::324e:abcd
5931 0: a123:b342::324e:abcd
5932 1:
5933    a123:ddde:b342::324e:abcd
5934 0: a123:ddde:b342::324e:abcd
5935 1:
5936    a123:ddde:b342::324e:dcba:abcd
5937 0: a123:ddde:b342::324e:dcba:abcd
5938 1:
5939    a123:ddde:9999:b342::324e:dcba:abcd
5940 0: a123:ddde:9999:b342::324e:dcba:abcd
5941 1:
5942\= Expect no match
5943    1:2:3:4:5:6:7:8
5944No match
5945    a123:bce:ddde:9999:b342::324e:dcba:abcd
5946No match
5947    a123::9999:b342::324e:dcba:abcd
5948No match
5949    abcde:2:3:4:5:6:7:8
5950No match
5951    ::1
5952No match
5953    abcd:fee0:123::
5954No match
5955    :1
5956No match
5957    1:
5958No match
5959
5960/[z\Qa-d]\E]/
5961    z
5962 0: z
5963    a
5964 0: a
5965    -
5966 0: -
5967    d
5968 0: d
5969    ]
5970 0: ]
5971\= Expect no match
5972    b
5973No match
5974
5975/(a+)*b/
5976\= Expect no match
5977    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
5978No match
5979
5980/(?i)reg(?:ul(?:[a�]|ae)r|ex)/
5981    REGular
5982 0: REGular
5983    regulaer
5984 0: regulaer
5985    Regex
5986 0: Regex
5987    regul�r
5988 0: regul\xe4r
5989
5990/����[�-��-�]+/
5991    �����
5992 0: \xc5\xe6\xe5\xe4\xe0
5993    �����
5994 0: \xc5\xe6\xe5\xe4\xff
5995    �����
5996 0: \xc5\xe6\xe5\xe4\xc0
5997    �����
5998 0: \xc5\xe6\xe5\xe4\xdf
5999
6000/(?<=Z)X./
6001  \x84XAZXB
6002 0: XB
6003
6004/ab cd (?x) de fg/
6005    ab cd defg
6006 0: ab cd defg
6007
6008/ab cd(?x) de fg/
6009    ab cddefg
6010 0: ab cddefg
6011\= Expect no match
6012    abcddefg
6013No match
6014
6015/(?<![^f]oo)(bar)/
6016    foobarX
6017 0: bar
6018 1: bar
6019\= Expect no match
6020    boobarX
6021No match
6022
6023/(?<![^f])X/
6024    offX
6025 0: X
6026\= Expect no match
6027    onyX
6028No match
6029
6030/(?<=[^f])X/
6031    onyX
6032 0: X
6033\= Expect no match
6034    offX
6035No match
6036
6037/^/gm
6038    a\nb\nc\n
6039 0:
6040 0:
6041 0:
6042    \
6043 0:
6044
6045/(?<=C\n)^/gm
6046    A\nC\nC\n
6047 0:
6048
6049/(?:(?(1)a|b)(X))+/
6050    bXaX
6051 0: bXaX
6052 1: X
6053
6054/(?:(?(1)\1a|b)(X|Y))+/
6055    bXXaYYaY
6056 0: bXXaYYaY
6057 1: Y
6058    bXYaXXaX
6059 0: bX
6060 1: X
6061
6062/()()()()()()()()()(?:(?(10)\10a|b)(X|Y))+/
6063    bXXaYYaY
6064 0: bX
6065 1:
6066 2:
6067 3:
6068 4:
6069 5:
6070 6:
6071 7:
6072 8:
6073 9:
607410: X
6075
6076/[[,abc,]+]/
6077    abc]
6078 0: abc]
6079    a,b]
6080 0: a,b]
6081    [a,b,c]
6082 0: [a,b,c]
6083
6084/(?-x: )/x
6085    A\x20B
6086 0:
6087
6088/(?x)(?-x: \s*#\s*)/
6089    A # B
6090 0:  #
6091\= Expect no match
6092    #
6093No match
6094    A s#s B
6095No match
6096
6097/(?x-is)(?:(?-ixs) \s*#\s*) include/
6098    A #include
6099 0:  #include
6100\= Expect no match
6101    A#include
6102No match
6103    A #Include
6104No match
6105
6106/a*b*\w/
6107    aaabbbb
6108 0: aaabbbb
6109    aaaa
6110 0: aaaa
6111    a
6112 0: a
6113
6114/a*b?\w/
6115    aaabbbb
6116 0: aaabb
6117    aaaa
6118 0: aaaa
6119    a
6120 0: a
6121
6122/a*b{0,4}\w/
6123    aaabbbb
6124 0: aaabbbb
6125    aaaa
6126 0: aaaa
6127    a
6128 0: a
6129
6130/a*b{0,}\w/
6131    aaabbbb
6132 0: aaabbbb
6133    aaaa
6134 0: aaaa
6135    a
6136 0: a
6137
6138/a*\d*\w/
6139    0a
6140 0: 0a
6141    a
6142 0: a
6143
6144/a*b *\w/x
6145    a
6146 0: a
6147
6148/a*b#comment
6149  *\w/x
6150    a
6151 0: a
6152
6153/a* b *\w/x
6154    a
6155 0: a
6156
6157/^\w+=.*(\\\n.*)*/
6158    abc=xyz\\\npqr
6159 0: abc=xyz\
6160
6161/(?=(\w+))\1:/
6162    abcd:
6163 0: abcd:
6164 1: abcd
6165
6166/^(?=(\w+))\1:/
6167    abcd:
6168 0: abcd:
6169 1: abcd
6170
6171/^\Eabc/
6172    abc
6173 0: abc
6174
6175/^[\Eabc]/
6176    a
6177 0: a
6178\= Expect no match
6179    E
6180No match
6181
6182/^[a-\Ec]/
6183    b
6184 0: b
6185\= Expect no match
6186    -
6187No match
6188    E
6189No match
6190
6191/^[a\E\E-\Ec]/
6192    b
6193 0: b
6194\= Expect no match
6195    -
6196No match
6197    E
6198No match
6199
6200/^[\E\Qa\E-\Qz\E]+/
6201    b
6202 0: b
6203\= Expect no match
6204    -
6205No match
6206
6207/^[a\Q]bc\E]/
6208    a
6209 0: a
6210    ]
6211 0: ]
6212    c
6213 0: c
6214
6215/^[a-\Q\E]/
6216    a
6217 0: a
6218    -
6219 0: -
6220
6221/^(a()*)*/
6222    aaaa
6223 0: aaaa
6224 1: a
6225 2:
6226
6227/^(?:a(?:(?:))*)*/
6228    aaaa
6229 0: aaaa
6230
6231/^(a()+)+/
6232    aaaa
6233 0: aaaa
6234 1: a
6235 2:
6236
6237/^(?:a(?:(?:))+)+/
6238    aaaa
6239 0: aaaa
6240
6241/(a){0,3}(?(1)b|(c|))*D/
6242    abbD
6243 0: abbD
6244 1: a
6245    ccccD
6246 0: ccccD
6247 1: <unset>
6248 2:
6249    D
6250 0: D
6251 1: <unset>
6252 2:
6253
6254/(a|)*\d/
6255  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
6256 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
6257 1:
6258\= Expect no match
6259  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
6260No match
6261
6262/(?>a|)*\d/
6263  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
6264 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
6265\= Expect no match
6266  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
6267No match
6268
6269/(?:a|)*\d/
6270  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
6271 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
6272\= Expect no match
6273  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
6274No match
6275
6276/\Z/g
6277  abc\n
6278 0:
6279 0:
6280
6281/^(?s)(?>.*)(?<!\n)/
6282  abc
6283 0: abc
6284\= Expect no match
6285  abc\n
6286No match
6287
6288/^(?![^\n]*\n\z)/
6289  abc
6290 0:
6291\= Expect no match
6292  abc\n
6293No match
6294
6295/\z(?<!\n)/
6296  abc
6297 0:
6298\= Expect no match
6299  abc\n
6300No match
6301
6302/(.*(.)?)*/
6303    abcd
6304 0: abcd
6305 1:
6306
6307/( (A | (?(1)0|) )*   )/x
6308    abcd
6309 0:
6310 1:
6311 2:
6312
6313/( ( (?(1)0|) )*   )/x
6314    abcd
6315 0:
6316 1:
6317 2:
6318
6319/(  (?(1)0|)*   )/x
6320    abcd
6321 0:
6322 1:
6323
6324/[[:abcd:xyz]]/
6325    a]
6326 0: a]
6327    :]
6328 0: :]
6329
6330/[abc[:x\]pqr]/
6331    a
6332 0: a
6333    [
6334 0: [
6335    :
6336 0: :
6337    ]
6338 0: ]
6339    p
6340 0: p
6341
6342/.*[op][xyz]/
6343\= Expect no match
6344    fooabcfoo
6345No match
6346
6347/(?(?=.*b)b|^)/
6348   adc
6349 0:
6350   abc
6351 0: b
6352
6353/(?(?=^.*b)b|^)/
6354   adc
6355 0:
6356\= Expect no match
6357   abc
6358No match
6359
6360/(?(?=.*b)b|^)*/
6361   adc
6362 0:
6363   abc
6364 0:
6365
6366/(?(?=.*b)b|^)+/
6367   adc
6368 0:
6369   abc
6370 0: b
6371
6372/(?(?=b).*b|^d)/
6373    abc
6374 0: b
6375
6376/(?(?=.*b).*b|^d)/
6377    abc
6378 0: ab
6379
6380/^%((?(?=[a])[^%])|b)*%$/
6381    %ab%
6382 0: %ab%
6383 1:
6384
6385/(?i)a(?-i)b|c/
6386    XabX
6387 0: ab
6388    XAbX
6389 0: Ab
6390    CcC
6391 0: c
6392\= Expect no match
6393    XABX
6394No match
6395
6396/[\x00-\xff\s]+/
6397    \x0a\x0b\x0c\x0d
6398 0: \x0a\x0b\x0c\x0d
6399
6400/(abc)\1/i
6401\= Expect no match
6402   abc
6403No match
6404
6405/(abc)\1/
6406\= Expect no match
6407   abc
6408No match
6409
6410/[^a]*/i
6411    12abc
6412 0: 12
6413    12ABC
6414 0: 12
6415
6416/[^a]*+/i
6417    12abc
6418 0: 12
6419    12ABC
6420 0: 12
6421
6422/[^a]*?X/i
6423\= Expect no match
6424    12abc
6425No match
6426    12ABC
6427No match
6428
6429/[^a]+?X/i
6430\= Expect no match
6431    12abc
6432No match
6433    12ABC
6434No match
6435
6436/[^a]?X/i
6437    12aXbcX
6438 0: X
6439    12AXBCX
6440 0: X
6441    BCX
6442 0: CX
6443
6444/[^a]??X/i
6445    12aXbcX
6446 0: X
6447    12AXBCX
6448 0: X
6449    BCX
6450 0: CX
6451
6452/[^a]?+X/i
6453    12aXbcX
6454 0: cX
6455    12AXBCX
6456 0: CX
6457    BCX
6458 0: CX
6459
6460/[^a]{2,3}/i
6461    abcdef
6462 0: bcd
6463    ABCDEF
6464 0: BCD
6465
6466/[^a]{2,3}?/i
6467    abcdef
6468 0: bc
6469    ABCDEF
6470 0: BC
6471
6472/[^a]{2,3}+/i
6473    abcdef
6474 0: bcd
6475    ABCDEF
6476 0: BCD
6477
6478/((a|)+)+Z/
6479    Z
6480 0: Z
6481 1:
6482 2:
6483
6484/(a)b|(a)c/
6485    ac
6486 0: ac
6487 1: <unset>
6488 2: a
6489
6490/(?>(a))b|(a)c/
6491    ac
6492 0: ac
6493 1: <unset>
6494 2: a
6495
6496/(?=(a))ab|(a)c/
6497    ac
6498 0: ac
6499 1: <unset>
6500 2: a
6501
6502/((?>(a))b|(a)c)/
6503    ac
6504 0: ac
6505 1: ac
6506 2: <unset>
6507 3: a
6508
6509/((?>(a))b|(a)c)++/
6510    ac
6511 0: ac
6512 1: ac
6513 2: <unset>
6514 3: a
6515
6516/(?:(?>(a))b|(a)c)++/
6517    ac
6518 0: ac
6519 1: <unset>
6520 2: a
6521
6522/(?=(?>(a))b|(a)c)(..)/
6523    ac
6524 0: ac
6525 1: <unset>
6526 2: a
6527 3: ac
6528
6529/(?>(?>(a))b|(a)c)/
6530    ac
6531 0: ac
6532 1: <unset>
6533 2: a
6534
6535/(?:(?>([ab])))+a=/aftertext
6536    =ba=
6537 0: ba=
6538 0+
6539 1: b
6540
6541/(?>([ab]))+a=/aftertext
6542    =ba=
6543 0: ba=
6544 0+
6545 1: b
6546
6547/((?>(a+)b)+(aabab))/
6548    aaaabaaabaabab
6549 0: aaaabaaabaabab
6550 1: aaaabaaabaabab
6551 2: aaa
6552 3: aabab
6553
6554/(?>a+|ab)+?c/
6555\= Expect no match
6556    aabc
6557No match
6558
6559/(?>a+|ab)+c/
6560\= Expect no match
6561    aabc
6562No match
6563
6564/(?:a+|ab)+c/
6565    aabc
6566 0: aabc
6567
6568/(?(?=(a))a)/
6569    a
6570 0: a
6571 1: a
6572
6573/(?(?=(a))a)(b)/
6574    ab
6575 0: ab
6576 1: a
6577 2: b
6578
6579/^(?:a|ab)++c/
6580\= Expect no match
6581    aaaabc
6582No match
6583
6584/^(?>a|ab)++c/
6585\= Expect no match
6586    aaaabc
6587No match
6588
6589/^(?:a|ab)+c/
6590    aaaabc
6591 0: aaaabc
6592
6593/(?=abc){3}abc/aftertext
6594    abcabcabc
6595 0: abc
6596 0+ abcabc
6597\= Expect no match
6598    xyz
6599No match
6600
6601/(?=abc)+abc/aftertext
6602    abcabcabc
6603 0: abc
6604 0+ abcabc
6605\= Expect no match
6606    xyz
6607No match
6608
6609/(?=abc)++abc/aftertext
6610    abcabcabc
6611 0: abc
6612 0+ abcabc
6613\= Expect no match
6614    xyz
6615No match
6616
6617/(?=abc){0}xyz/
6618    xyz
6619 0: xyz
6620
6621/(?=abc){1}xyz/
6622\= Expect no match
6623    xyz
6624No match
6625
6626/(?=(a))?./
6627    ab
6628 0: a
6629 1: a
6630    bc
6631 0: b
6632
6633/(?=(a))??./
6634    ab
6635 0: a
6636    bc
6637 0: b
6638
6639/^(?=(?1))?[az]([abc])d/
6640    abd
6641 0: abd
6642 1: b
6643    zcdxx
6644 0: zcd
6645 1: c
6646
6647/^(?!a){0}\w+/
6648    aaaaa
6649 0: aaaaa
6650
6651/(?<=(abc))?xyz/
6652    abcxyz
6653 0: xyz
6654 1: abc
6655    pqrxyz
6656 0: xyz
6657
6658/^[\g<a>]+/
6659    ggg<<<aaa>>>
6660 0: ggg<<<aaa>>>
6661\= Expect no match
6662    \\ga
6663No match
6664
6665/^[\ga]+/
6666    gggagagaxyz
6667 0: gggagaga
6668
6669/^[:a[:digit:]]+/
6670    aaaa444:::Z
6671 0: aaaa444:::
6672
6673/^[:a[:digit:]:b]+/
6674    aaaa444:::bbbZ
6675 0: aaaa444:::bbb
6676
6677/[:a]xxx[b:]/
6678     :xxx:
6679 0: :xxx:
6680
6681/(?<=a{2})b/i
6682    xaabc
6683 0: b
6684\= Expect no match
6685    xabc
6686No match
6687
6688/(?<!a{2})b/i
6689    xabc
6690 0: b
6691\= Expect no match
6692    xaabc
6693No match
6694
6695/(?<=a\h)c/
6696    xa c
6697 0: c
6698
6699/(?<=[^a]{2})b/
6700    axxbc
6701 0: b
6702    aAAbc
6703 0: b
6704\= Expect no match
6705    xaabc
6706No match
6707
6708/(?<=[^a]{2})b/i
6709    axxbc
6710 0: b
6711\= Expect no match
6712    aAAbc
6713No match
6714    xaabc
6715No match
6716
6717/(?<=a\H)c/
6718    abc
6719 0: c
6720
6721/(?<=a\V)c/
6722    abc
6723 0: c
6724
6725/(?<=a\v)c/
6726    a\nc
6727 0: c
6728
6729/(?(?=c)c|d)++Y/
6730    XcccddYX
6731 0: cccddY
6732
6733/(?(?=c)c|d)*+Y/
6734    XcccddYX
6735 0: cccddY
6736
6737/^(a{2,3}){2,}+a/
6738    aaaaaaa
6739 0: aaaaaaa
6740 1: aaa
6741\= Expect no match
6742    aaaaaa
6743No match
6744    aaaaaaaaa
6745No match
6746
6747/^(a{2,3})++a/
6748\= Expect no match
6749    aaaaaa
6750No match
6751
6752/^(a{2,3})*+a/
6753\= Expect no match
6754    aaaaaa
6755No match
6756
6757/\H\h\V\v/
6758    X X\x0a
6759 0: X X\x0a
6760    X\x09X\x0b
6761 0: X\x09X\x0b
6762\= Expect no match
6763    \xa0 X\x0a
6764No match
6765
6766/\H*\h+\V?\v{3,4}/
6767    \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
6768 0: \x09 \xa0X\x0a\x0b\x0c\x0d
6769    \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
6770 0: \x09 \xa0\x0a\x0b\x0c\x0d
6771    \x09\x20\xa0\x0a\x0b\x0c
6772 0: \x09 \xa0\x0a\x0b\x0c
6773\= Expect no match
6774    \x09\x20\xa0\x0a\x0b
6775No match
6776
6777/\H{3,4}/
6778    XY  ABCDE
6779 0: ABCD
6780    XY  PQR ST
6781 0: PQR
6782
6783/.\h{3,4}./
6784    XY  AB    PQRS
6785 0: B    P
6786
6787/\h*X\h?\H+Y\H?Z/
6788    >XNNNYZ
6789 0: XNNNYZ
6790    >  X NYQZ
6791 0:   X NYQZ
6792\= Expect no match
6793    >XYZ
6794No match
6795    >  X NY Z
6796No match
6797
6798/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
6799    >XY\x0aZ\x0aA\x0bNN\x0c
6800 0: XY\x0aZ\x0aA\x0bNN\x0c
6801    >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
6802 0: \x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
6803
6804/(foo)\Kbar/
6805    foobar
6806 0: bar
6807 1: foo
6808
6809/(foo)(\Kbar|baz)/
6810    foobar
6811 0: bar
6812 1: foo
6813 2: bar
6814    foobaz
6815 0: foobaz
6816 1: foo
6817 2: baz
6818
6819/(foo\Kbar)baz/
6820    foobarbaz
6821 0: barbaz
6822 1: foobar
6823
6824/abc\K|def\K/g,aftertext
6825    Xabcdefghi
6826 0:
6827 0+ defghi
6828 0:
6829 0+ ghi
6830
6831/ab\Kc|de\Kf/g,aftertext
6832    Xabcdefghi
6833 0: c
6834 0+ defghi
6835 0: f
6836 0+ ghi
6837
6838/(?=C)/g,aftertext
6839    ABCDECBA
6840 0:
6841 0+ CDECBA
6842 0:
6843 0+ CBA
6844
6845/^abc\K/aftertext
6846    abcdef
6847 0:
6848 0+ def
6849\= Expect no match
6850    defabcxyz
6851No match
6852
6853/^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-2}Z/
6854    ababababbbabZXXXX
6855 0: ababababbbabZ
6856 1: ab
6857 2: b
6858
6859/(?<A>tom|bon)-\g{A}/
6860    tom-tom
6861 0: tom-tom
6862 1: tom
6863    bon-bon
6864 0: bon-bon
6865 1: bon
6866
6867/(^(a|b\g{-1}))/
6868\= Expect no match
6869    bacxxx
6870No match
6871
6872/(?|(abc)|(xyz))\1/
6873    abcabc
6874 0: abcabc
6875 1: abc
6876    xyzxyz
6877 0: xyzxyz
6878 1: xyz
6879\= Expect no match
6880    abcxyz
6881No match
6882    xyzabc
6883No match
6884
6885/(?|(abc)|(xyz))(?1)/
6886    abcabc
6887 0: abcabc
6888 1: abc
6889    xyzabc
6890 0: xyzabc
6891 1: xyz
6892\= Expect no match
6893    xyzxyz
6894No match
6895
6896/^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/
6897    XYabcdY
6898 0: XYabcdY
6899 1: a
6900 2: b
6901 3: c
6902 4: d
6903 5: Y
6904
6905/^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/
6906    XYabcdY
6907 0: XYabcdY
6908 1: a
6909 2: b
6910 3: <unset>
6911 4: <unset>
6912 5: c
6913 6: d
6914 7: Y
6915
6916/^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/
6917    XYabcdY
6918 0: XYabcdY
6919 1: a
6920 2: b
6921 3: <unset>
6922 4: <unset>
6923 5: c
6924 6: d
6925 7: Y
6926
6927/(?'abc'\w+):\k<abc>{2}/
6928    a:aaxyz
6929 0: a:aa
6930 1: a
6931    ab:ababxyz
6932 0: ab:abab
6933 1: ab
6934\= Expect no match
6935    a:axyz
6936No match
6937    ab:abxyz
6938No match
6939
6940/(?'abc'\w+):\g{abc}{2}/
6941    a:aaxyz
6942 0: a:aa
6943 1: a
6944    ab:ababxyz
6945 0: ab:abab
6946 1: ab
6947\= Expect no match
6948    a:axyz
6949No match
6950    ab:abxyz
6951No match
6952
6953/^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
6954    abd
6955 0: abd
6956 1: a
6957    ce
6958 0: ce
6959
6960/^(a.)\g-1Z/
6961    aXaXZ
6962 0: aXaXZ
6963 1: aX
6964
6965/^(a.)\g{-1}Z/
6966    aXaXZ
6967 0: aXaXZ
6968 1: aX
6969
6970/^(?(DEFINE) (?<A> a) (?<B> b) )  (?&A) (?&B) /x
6971    abcd
6972 0: ab
6973
6974/(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
6975  (?(DEFINE)
6976  (?<NAME_PAT>[a-z]+)
6977  (?<ADDRESS_PAT>\d+)
6978  )/x
6979    metcalfe 33
6980 0: metcalfe 33
6981 1: metcalfe
6982 2: 33
6983
6984/(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
6985    1.2.3.4
6986 0: 1.2.3.4
6987 1: <unset>
6988 2: .4
6989    131.111.10.206
6990 0: 131.111.10.206
6991 1: <unset>
6992 2: .206
6993    10.0.0.0
6994 0: 10.0.0.0
6995 1: <unset>
6996 2: .0
6997\= Expect no match
6998    10.6
6999No match
7000    455.3.4.5
7001No match
7002
7003/\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
7004    1.2.3.4
7005 0: 1.2.3.4
7006 1: .4
7007    131.111.10.206
7008 0: 131.111.10.206
7009 1: .206
7010    10.0.0.0
7011 0: 10.0.0.0
7012 1: .0
7013\= Expect no match
7014    10.6
7015No match
7016    455.3.4.5
7017No match
7018
7019/^(\w++|\s++)*$/
7020    now is the time for all good men to come to the aid of the party
7021 0: now is the time for all good men to come to the aid of the party
7022 1: party
7023\= Expect no match
7024    this is not a line with only words and spaces!
7025No match
7026
7027/(\d++)(\w)/
7028    12345a
7029 0: 12345a
7030 1: 12345
7031 2: a
7032\= Expect no match
7033    12345+
7034No match
7035
7036/a++b/
7037    aaab
7038 0: aaab
7039
7040/(a++b)/
7041    aaab
7042 0: aaab
7043 1: aaab
7044
7045/(a++)b/
7046    aaab
7047 0: aaab
7048 1: aaa
7049
7050/([^()]++|\([^()]*\))+/
7051    ((abc(ade)ufh()()x
7052 0: abc(ade)ufh()()x
7053 1: x
7054
7055/\(([^()]++|\([^()]+\))+\)/
7056    (abc)
7057 0: (abc)
7058 1: abc
7059    (abc(def)xyz)
7060 0: (abc(def)xyz)
7061 1: xyz
7062\= Expect no match
7063    ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
7064No match
7065
7066/^([^()]|\((?1)*\))*$/
7067    abc
7068 0: abc
7069 1: c
7070    a(b)c
7071 0: a(b)c
7072 1: c
7073    a(b(c))d
7074 0: a(b(c))d
7075 1: d
7076\= Expect no match)
7077    a(b(c)d
7078No match
7079
7080/^>abc>([^()]|\((?1)*\))*<xyz<$/
7081   >abc>123<xyz<
7082 0: >abc>123<xyz<
7083 1: 3
7084   >abc>1(2)3<xyz<
7085 0: >abc>1(2)3<xyz<
7086 1: 3
7087   >abc>(1(2)3)<xyz<
7088 0: >abc>(1(2)3)<xyz<
7089 1: (1(2)3)
7090
7091/^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/i
7092    1221
7093 0: 1221
7094 1: 1221
7095 2: 1
7096    Satanoscillatemymetallicsonatas
7097 0: Satanoscillatemymetallicsonatas
7098 1: <unset>
7099 2: <unset>
7100 3: Satanoscillatemymetallicsonatas
7101 4: S
7102    AmanaplanacanalPanama
7103 0: AmanaplanacanalPanama
7104 1: <unset>
7105 2: <unset>
7106 3: AmanaplanacanalPanama
7107 4: A
7108    AblewasIereIsawElba
7109 0: AblewasIereIsawElba
7110 1: <unset>
7111 2: <unset>
7112 3: AblewasIereIsawElba
7113 4: A
7114\= Expect no match
7115    Thequickbrownfox
7116No match
7117
7118/^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
7119    12
7120 0: 12
7121 1: 12
7122    (((2+2)*-3)-7)
7123 0: (((2+2)*-3)-7)
7124 1: (((2+2)*-3)-7)
7125 2: -
7126    -12
7127 0: -12
7128 1: -12
7129\= Expect no match
7130    ((2+2)*-3)-7)
7131No match
7132
7133/^(x(y|(?1){2})z)/
7134    xyz
7135 0: xyz
7136 1: xyz
7137 2: y
7138    xxyzxyzz
7139 0: xxyzxyzz
7140 1: xxyzxyzz
7141 2: xyzxyz
7142\= Expect no match
7143    xxyzz
7144No match
7145    xxyzxyzxyzz
7146No match
7147
7148/((< (?: (?(R) \d++  | [^<>]*+) | (?2)) * >))/x
7149    <>
7150 0: <>
7151 1: <>
7152 2: <>
7153    <abcd>
7154 0: <abcd>
7155 1: <abcd>
7156 2: <abcd>
7157    <abc <123> hij>
7158 0: <abc <123> hij>
7159 1: <abc <123> hij>
7160 2: <abc <123> hij>
7161    <abc <def> hij>
7162 0: <def>
7163 1: <def>
7164 2: <def>
7165    <abc<>def>
7166 0: <abc<>def>
7167 1: <abc<>def>
7168 2: <abc<>def>
7169    <abc<>
7170 0: <>
7171 1: <>
7172 2: <>
7173\= Expect no match
7174    <abc
7175No match
7176
7177/^a+(*FAIL)/
7178\= Expect no match
7179    aaaaaa
7180No match
7181
7182/a+b?c+(*FAIL)/
7183\= Expect no match
7184    aaabccc
7185No match
7186
7187/a+b?(*PRUNE)c+(*FAIL)/
7188\= Expect no match
7189    aaabccc
7190No match
7191
7192/a+b?(*COMMIT)c+(*FAIL)/
7193\= Expect no match
7194    aaabccc
7195No match
7196
7197/a+b?(*SKIP)c+(*FAIL)/
7198\= Expect no match
7199    aaabcccaaabccc
7200No match
7201
7202/^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
7203    aaaxxxxxx
7204 0: aaaxxxxxx
7205    aaa++++++
7206 0: aaa
7207    bbbxxxxx
7208 0: bbbxxxxx
7209    bbb+++++
7210 0: bbb
7211    cccxxxx
7212 0: cccxxxx
7213    ccc++++
7214 0: ccc
7215    dddddddd
7216 0: ddd
7217
7218/^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
7219    aaaxxxxxx
7220 0: aaaxxxxxx
7221 1: aaaxxxxxx
7222    aaa++++++
7223 0: aaa
7224 1: aaa
7225    bbbxxxxx
7226 0: bbbxxxxx
7227 1: bbbxxxxx
7228    bbb+++++
7229 0: bbb
7230 1: bbb
7231    cccxxxx
7232 0: cccxxxx
7233 1: cccxxxx
7234    ccc++++
7235 0: ccc
7236 1: ccc
7237    dddddddd
7238 0: ddd
7239 1: ddd
7240
7241/a+b?(*THEN)c+(*FAIL)/
7242\= Expect no match
7243    aaabccc
7244No match
7245
7246/(A (A|B(*ACCEPT)|C) D)(E)/x
7247    AB
7248 0: AB
7249 1: AB
7250 2: B
7251    ABX
7252 0: AB
7253 1: AB
7254 2: B
7255    AADE
7256 0: AADE
7257 1: AAD
7258 2: A
7259 3: E
7260    ACDE
7261 0: ACDE
7262 1: ACD
7263 2: C
7264 3: E
7265\= Expect no match
7266    AD
7267No match
7268
7269/^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
7270    1221
7271 0: 1221
7272 1: 1221
7273 2: 1
7274    Satan, oscillate my metallic sonatas!
7275 0: Satan, oscillate my metallic sonatas!
7276 1: <unset>
7277 2: <unset>
7278 3: Satan, oscillate my metallic sonatas
7279 4: S
7280    A man, a plan, a canal: Panama!
7281 0: A man, a plan, a canal: Panama!
7282 1: <unset>
7283 2: <unset>
7284 3: A man, a plan, a canal: Panama
7285 4: A
7286    Able was I ere I saw Elba.
7287 0: Able was I ere I saw Elba.
7288 1: <unset>
7289 2: <unset>
7290 3: Able was I ere I saw Elba
7291 4: A
7292\= Expect no match
7293    The quick brown fox
7294No match
7295
7296/^((.)(?1)\2|.)$/
7297    a
7298 0: a
7299 1: a
7300    aba
7301 0: aba
7302 1: aba
7303 2: a
7304    aabaa
7305 0: aabaa
7306 1: aabaa
7307 2: a
7308    abcdcba
7309 0: abcdcba
7310 1: abcdcba
7311 2: a
7312    pqaabaaqp
7313 0: pqaabaaqp
7314 1: pqaabaaqp
7315 2: p
7316    ablewasiereisawelba
7317 0: ablewasiereisawelba
7318 1: ablewasiereisawelba
7319 2: a
7320\= Expect no match
7321    rhubarb
7322No match
7323    the quick brown fox
7324No match
7325
7326/(a)(?<=b(?1))/
7327    baz
7328 0: a
7329 1: a
7330\= Expect no match
7331    caz
7332No match
7333
7334/(?<=b(?1))(a)/
7335    zbaaz
7336 0: a
7337 1: a
7338\= Expect no match
7339    aaa
7340No match
7341
7342/(?<X>a)(?<=b(?&X))/
7343    baz
7344 0: a
7345 1: a
7346
7347/^(?|(abc)|(def))\1/
7348    abcabc
7349 0: abcabc
7350 1: abc
7351    defdef
7352 0: defdef
7353 1: def
7354\= Expect no match
7355    abcdef
7356No match
7357    defabc
7358No match
7359
7360/^(?|(abc)|(def))(?1)/
7361    abcabc
7362 0: abcabc
7363 1: abc
7364    defabc
7365 0: defabc
7366 1: def
7367\= Expect no match
7368    defdef
7369No match
7370    abcdef
7371No match
7372
7373/(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |b(?<quote> (?<apostrophe>')|(?<realquote>")) ) (?('quote')[a-z]+|[0-9]+)/x,dupnames
7374    a\"aaaaa
7375 0: a"aaaaa
7376 1: "
7377 2: <unset>
7378 3: "
7379    b\"aaaaa
7380 0: b"aaaaa
7381 1: <unset>
7382 2: <unset>
7383 3: <unset>
7384 4: "
7385 5: <unset>
7386 6: "
7387\= Expect no match
7388    b\"11111
7389No match
7390
7391/(?:(?1)|B)(A(*F)|C)/
7392    ABCD
7393 0: BC
7394 1: C
7395    CCD
7396 0: CC
7397 1: C
7398\= Expect no match
7399    CAD
7400No match
7401
7402/^(?:(?1)|B)(A(*F)|C)/
7403    CCD
7404 0: CC
7405 1: C
7406    BCD
7407 0: BC
7408 1: C
7409\= Expect no match
7410    ABCD
7411No match
7412    CAD
7413No match
7414    BAD
7415No match
7416
7417/(?:(?1)|B)(A(*ACCEPT)XX|C)D/
7418    AAD
7419 0: AA
7420 1: A
7421    ACD
7422 0: ACD
7423 1: C
7424    BAD
7425 0: BA
7426 1: A
7427    BCD
7428 0: BCD
7429 1: C
7430    BAX
7431 0: BA
7432 1: A
7433\= Expect no match
7434    ACX
7435No match
7436    ABC
7437No match
7438
7439/(?(DEFINE)(A))B(?1)C/
7440    BAC
7441 0: BAC
7442
7443/(?(DEFINE)((A)\2))B(?1)C/
7444    BAAC
7445 0: BAAC
7446
7447/(?<pn> \( ( [^()]++ | (?&pn) )* \) )/x
7448    (ab(cd)ef)
7449 0: (ab(cd)ef)
7450 1: (ab(cd)ef)
7451 2: ef
7452
7453/^(?=a(*SKIP)b|ac)/
7454\= Expect no match
7455    ac
7456No match
7457
7458/^(?=a(*PRUNE)b)/
7459    ab
7460 0:
7461\= Expect no match
7462    ac
7463No match
7464
7465/^(?=a(*ACCEPT)b)/
7466    ac
7467 0:
7468
7469/(?>a\Kb)/
7470    ab
7471 0: b
7472
7473/((?>a\Kb))/
7474    ab
7475 0: b
7476 1: ab
7477
7478/(a\Kb)/
7479    ab
7480 0: b
7481 1: ab
7482
7483/^a\Kcz|ac/
7484    ac
7485 0: ac
7486
7487/(?>a\Kbz|ab)/
7488    ab
7489 0: ab
7490
7491/^(?&t)(?(DEFINE)(?<t>a\Kb))$/
7492    ab
7493 0: b
7494
7495/^([^()]|\((?1)*\))*$/
7496    a(b)c
7497 0: a(b)c
7498 1: c
7499    a(b(c)d)e
7500 0: a(b(c)d)e
7501 1: e
7502
7503/(?P<L1>(?P<L2>0)(?P>L1)|(?P>L2))/
7504    0
7505 0: 0
7506 1: 0
7507    00
7508 0: 00
7509 1: 00
7510 2: 0
7511    0000
7512 0: 0000
7513 1: 0000
7514 2: 0
7515
7516/(?P<L1>(?P<L2>0)|(?P>L2)(?P>L1))/
7517    0
7518 0: 0
7519 1: 0
7520 2: 0
7521    00
7522 0: 0
7523 1: 0
7524 2: 0
7525    0000
7526 0: 0
7527 1: 0
7528 2: 0
7529
7530# This one does fail, as expected, in Perl. It needs the complex item at the
7531# end of the pattern. A single letter instead of (B|D) makes it not fail, which
7532# I think is a Perl bug.
7533
7534/A(*COMMIT)(B|D)/
7535\= Expect no match
7536    ACABX
7537No match
7538
7539# Check the use of names for failure
7540
7541/^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
7542\= Expect no match
7543    AC
7544No match, mark = A
7545    CB
7546No match, mark = B
7547
7548/(*MARK:A)(*SKIP:B)(C|X)/mark
7549    C
7550 0: C
7551 1: C
7552MK: A
7553\= Expect no match
7554    D
7555No match, mark = A
7556
7557/^(A(*THEN:A)B|C(*THEN:B)D)/mark
7558\= Expect no match
7559    CB
7560No match, mark = B
7561
7562/^(?:A(*THEN:A)B|C(*THEN:B)D)/mark
7563\= Expect no match
7564    CB
7565No match, mark = B
7566
7567/^(?>A(*THEN:A)B|C(*THEN:B)D)/mark
7568\= Expect no match
7569    CB
7570No match, mark = B
7571
7572# This should succeed, as the skip causes bump to offset 1 (the mark). Note
7573# that we have to have something complicated such as (B|Z) at the end because,
7574# for Perl, a simple character somehow causes an unwanted optimization to mess
7575# with the handling of backtracking verbs.
7576
7577/A(*MARK:A)A+(*SKIP:A)(B|Z) | AC/x,mark
7578    AAAC
7579 0: AC
7580
7581# Test skipping over a non-matching mark.
7582
7583/A(*MARK:A)A+(*MARK:B)(*SKIP:A)(B|Z) | AC/x,mark
7584    AAAC
7585 0: AC
7586
7587# Check shorthand for MARK.
7588
7589/A(*:A)A+(*SKIP:A)(B|Z) | AC/x,mark
7590    AAAC
7591 0: AC
7592
7593/(*:A)A+(*SKIP:A)(B|Z)/mark
7594\= Expect no match
7595    AAAC
7596No match, mark = A
7597
7598# This should succeed, as a non-existent skip name disables the skip.
7599
7600/A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark
7601    AAAC
7602 0: AC
7603
7604/A(*MARK:A)A+(*SKIP:B)(B|Z) | AC(*:B)/x,mark
7605    AAAC
7606 0: AC
7607MK: B
7608
7609# COMMIT at the start of a pattern should act like an anchor. Again, however,
7610# we need the complication for Perl.
7611
7612/(*COMMIT)(A|P)(B|P)(C|P)/
7613    ABCDEFG
7614 0: ABC
7615 1: A
7616 2: B
7617 3: C
7618\= Expect no match
7619    DEFGABC
7620No match
7621
7622# COMMIT inside an atomic group can't stop backtracking over the group.
7623
7624/(\w+)(?>b(*COMMIT))\w{2}/
7625    abbb
7626 0: abbb
7627 1: a
7628
7629/(\w+)b(*COMMIT)\w{2}/
7630\= Expect no match
7631    abbb
7632No match
7633
7634# Check opening parens in comment when seeking forward reference.
7635
7636/(?&t)(?#()(?(DEFINE)(?<t>a))/
7637    bac
7638 0: a
7639
7640# COMMIT should override THEN.
7641
7642/(?>(*COMMIT)(?>yes|no)(*THEN)(*F))?/
7643\= Expect no match
7644  yes
7645No match
7646
7647/(?>(*COMMIT)(yes|no)(*THEN)(*F))?/
7648\= Expect no match
7649  yes
7650No match
7651
7652/b?(*SKIP)c/
7653    bc
7654 0: bc
7655    abc
7656 0: bc
7657
7658/(*SKIP)bc/
7659\= Expect no match
7660    a
7661No match
7662
7663/(*SKIP)b/
7664\= Expect no match
7665    a
7666No match
7667
7668/(?P<abn>(?P=abn)xxx|)+/
7669    xxx
7670 0:
7671 1:
7672
7673/(?i:([^b]))(?1)/
7674    aa
7675 0: aa
7676 1: a
7677    aA
7678 0: aA
7679 1: a
7680\= Expect no match
7681    ab
7682No match
7683    aB
7684No match
7685    Ba
7686No match
7687    ba
7688No match
7689
7690/^(?&t)*+(?(DEFINE)(?<t>a))\w$/
7691    aaaaaaX
7692 0: aaaaaaX
7693\= Expect no match
7694    aaaaaa
7695No match
7696
7697/^(?&t)*(?(DEFINE)(?<t>a))\w$/
7698    aaaaaaX
7699 0: aaaaaaX
7700    aaaaaa
7701 0: aaaaaa
7702
7703/^(a)*+(\w)/
7704    aaaaX
7705 0: aaaaX
7706 1: a
7707 2: X
7708    YZ
7709 0: Y
7710 1: <unset>
7711 2: Y
7712\= Expect no match
7713    aaaa
7714No match
7715
7716/^(?:a)*+(\w)/
7717    aaaaX
7718 0: aaaaX
7719 1: X
7720    YZ
7721 0: Y
7722 1: Y
7723\= Expect no match
7724    aaaa
7725No match
7726
7727/^(a)++(\w)/
7728    aaaaX
7729 0: aaaaX
7730 1: a
7731 2: X
7732\= Expect no match
7733    aaaa
7734No match
7735    YZ
7736No match
7737
7738/^(?:a)++(\w)/
7739    aaaaX
7740 0: aaaaX
7741 1: X
7742\= Expect no match
7743    aaaa
7744No match
7745    YZ
7746No match
7747
7748/^(a)?+(\w)/
7749    aaaaX
7750 0: aa
7751 1: a
7752 2: a
7753    YZ
7754 0: Y
7755 1: <unset>
7756 2: Y
7757
7758/^(?:a)?+(\w)/
7759    aaaaX
7760 0: aa
7761 1: a
7762    YZ
7763 0: Y
7764 1: Y
7765
7766/^(a){2,}+(\w)/
7767    aaaaX
7768 0: aaaaX
7769 1: a
7770 2: X
7771\= Expect no match
7772    aaa
7773No match
7774    YZ
7775No match
7776
7777/^(?:a){2,}+(\w)/
7778    aaaaX
7779 0: aaaaX
7780 1: X
7781\= Expect no match
7782    aaa
7783No match
7784    YZ
7785No match
7786
7787/(a|)*(?1)b/
7788    b
7789 0: b
7790 1:
7791    ab
7792 0: ab
7793 1:
7794    aab
7795 0: aab
7796 1:
7797
7798/(a)++(?1)b/
7799\= Expect no match
7800    ab
7801No match
7802    aab
7803No match
7804
7805/(a)*+(?1)b/
7806\= Expect no match
7807    ab
7808No match
7809    aab
7810No match
7811
7812/(?1)(?:(b)){0}/
7813    b
7814 0: b
7815
7816/(foo ( \( ((?:(?> [^()]+ )|(?2))*) \) ) )/x
7817    foo(bar(baz)+baz(bop))
7818 0: foo(bar(baz)+baz(bop))
7819 1: foo(bar(baz)+baz(bop))
7820 2: (bar(baz)+baz(bop))
7821 3: bar(baz)+baz(bop)
7822
7823/(A (A|B(*ACCEPT)|C) D)(E)/x
7824    AB
7825 0: AB
7826 1: AB
7827 2: B
7828
7829/\A.*?(a|bc)/
7830    ba
7831 0: ba
7832 1: a
7833
7834/\A.*?(?:a|bc)++/
7835    ba
7836 0: ba
7837
7838/\A.*?(a|bc)++/
7839    ba
7840 0: ba
7841 1: a
7842
7843/\A.*?(?:a|bc|d)/
7844    ba
7845 0: ba
7846
7847/(?:(b))++/
7848    beetle
7849 0: b
7850 1: b
7851
7852/(?(?=(a(*ACCEPT)z))a)/
7853    a
7854 0: a
7855 1: a
7856
7857/^(a)(?1)+ab/
7858    aaaab
7859 0: aaaab
7860 1: a
7861
7862/^(a)(?1)++ab/
7863\= Expect no match
7864    aaaab
7865No match
7866
7867/^(?=a(*:M))aZ/mark
7868    aZbc
7869 0: aZ
7870MK: M
7871
7872/^(?!(*:M)b)aZ/mark
7873    aZbc
7874 0: aZ
7875
7876/(?(DEFINE)(a))?b(?1)/
7877    backgammon
7878 0: ba
7879
7880/^\N+/
7881    abc\ndef
7882 0: abc
7883
7884/^\N{1,}/
7885    abc\ndef
7886 0: abc
7887
7888/(?(R)a+|(?R)b)/
7889    aaaabcde
7890 0: aaaab
7891
7892/(?(R)a+|((?R))b)/
7893    aaaabcde
7894 0: aaaab
7895 1: aaaa
7896
7897/((?(R)a+|(?1)b))/
7898    aaaabcde
7899 0: aaaab
7900 1: aaaab
7901
7902/((?(R1)a+|(?1)b))/
7903    aaaabcde
7904 0: aaaab
7905 1: aaaab
7906
7907/((?(R)a|(?1)))*/
7908    aaa
7909 0: aaa
7910 1: a
7911
7912/((?(R)a|(?1)))+/
7913    aaa
7914 0: aaa
7915 1: a
7916
7917/a(*:any
7918name)/mark
7919    abc
7920 0: a
7921MK: any \x0aname
7922
7923/(?>(?&t)c|(?&t))(?(DEFINE)(?<t>a|b(*PRUNE)c))/
7924    a
7925 0: a
7926    ba
7927 0: a
7928    bba
7929 0: a
7930
7931# Checking revised (*THEN) handling.
7932
7933# Capture
7934
7935/^.*? (a(*THEN)b) c/x
7936\= Expect no match
7937    aabc
7938No match
7939
7940/^.*? (a(*THEN)b|(*F)) c/x
7941    aabc
7942 0: aabc
7943 1: ab
7944
7945/^.*? ( (a(*THEN)b) | (*F) ) c/x
7946    aabc
7947 0: aabc
7948 1: ab
7949 2: ab
7950
7951/^.*? ( (a(*THEN)b) ) c/x
7952\= Expect no match
7953    aabc
7954No match
7955
7956# Non-capture
7957
7958/^.*? (?:a(*THEN)b) c/x
7959\= Expect no match
7960    aabc
7961No match
7962
7963/^.*? (?:a(*THEN)b|(*F)) c/x
7964    aabc
7965 0: aabc
7966
7967/^.*? (?: (?:a(*THEN)b) | (*F) ) c/x
7968    aabc
7969 0: aabc
7970
7971/^.*? (?: (?:a(*THEN)b) ) c/x
7972\= Expect no match
7973    aabc
7974No match
7975
7976# Atomic
7977
7978/^.*? (?>a(*THEN)b) c/x
7979\= Expect no match
7980    aabc
7981No match
7982
7983/^.*? (?>a(*THEN)b|(*F)) c/x
7984    aabc
7985 0: aabc
7986
7987/^.*? (?> (?>a(*THEN)b) | (*F) ) c/x
7988    aabc
7989 0: aabc
7990
7991/^.*? (?> (?>a(*THEN)b) ) c/x
7992\= Expect no match
7993    aabc
7994No match
7995
7996# Possessive capture
7997
7998/^.*? (a(*THEN)b)++ c/x
7999\= Expect no match
8000    aabc
8001No match
8002
8003/^.*? (a(*THEN)b|(*F))++ c/x
8004    aabc
8005 0: aabc
8006 1: ab
8007
8008/^.*? ( (a(*THEN)b)++ | (*F) )++ c/x
8009    aabc
8010 0: aabc
8011 1: ab
8012 2: ab
8013
8014/^.*? ( (a(*THEN)b)++ )++ c/x
8015\= Expect no match
8016    aabc
8017No match
8018
8019# Possessive non-capture
8020
8021/^.*? (?:a(*THEN)b)++ c/x
8022\= Expect no match
8023    aabc
8024No match
8025
8026/^.*? (?:a(*THEN)b|(*F))++ c/x
8027    aabc
8028 0: aabc
8029
8030/^.*? (?: (?:a(*THEN)b)++ | (*F) )++ c/x
8031    aabc
8032 0: aabc
8033
8034/^.*? (?: (?:a(*THEN)b)++ )++ c/x
8035\= Expect no match
8036    aabc
8037No match
8038
8039# Condition assertion
8040
8041/^(?(?=a(*THEN)b)ab|ac)/
8042    ac
8043 0: ac
8044
8045# Condition
8046
8047/^.*?(?(?=a)a|b(*THEN)c)/
8048\= Expect no match
8049    ba
8050No match
8051
8052/^.*?(?:(?(?=a)a|b(*THEN)c)|d)/
8053    ba
8054 0: ba
8055
8056/^.*?(?(?=a)a(*THEN)b|c)/
8057\= Expect no match
8058    ac
8059No match
8060
8061# Assertion
8062
8063/^.*(?=a(*THEN)b)/
8064    aabc
8065 0: a
8066
8067# --------------------------
8068
8069/(?>a(*:m))/imsx,mark
8070    a
8071 0: a
8072MK: m
8073
8074/(?>(a)(*:m))/imsx,mark
8075    a
8076 0: a
8077 1: a
8078MK: m
8079
8080/(?<=a(*ACCEPT)b)c/
8081    xacd
8082 0: c
8083
8084/(?<=(a(*ACCEPT)b))c/
8085    xacd
8086 0: c
8087 1: a
8088
8089/(?<=(a(*COMMIT)b))c/
8090    xabcd
8091 0: c
8092 1: ab
8093\= Expect no match
8094    xacd
8095No match
8096
8097/(?<!a(*FAIL)b)c/
8098    xcd
8099 0: c
8100    acd
8101 0: c
8102
8103/(?<=a(*:N)b)c/mark
8104    xabcd
8105 0: c
8106MK: N
8107
8108/(?<=a(*PRUNE)b)c/
8109    xabcd
8110 0: c
8111
8112/(?<=a(*SKIP)b)c/
8113    xabcd
8114 0: c
8115
8116/(?<=a(*THEN)b)c/
8117    xabcd
8118 0: c
8119
8120/(a)(?2){2}(.)/
8121    abcd
8122 0: abcd
8123 1: a
8124 2: d
8125
8126/(*MARK:A)(*PRUNE:B)(C|X)/mark
8127    C
8128 0: C
8129 1: C
8130MK: B
8131\= Expect no match
8132    D
8133No match, mark = B
8134
8135/(*MARK:A)(*PRUNE:B)(C|X)/mark
8136    C
8137 0: C
8138 1: C
8139MK: B
8140\= Expect no match
8141    D
8142No match, mark = B
8143
8144/(*MARK:A)(*THEN:B)(C|X)/mark
8145    C
8146 0: C
8147 1: C
8148MK: B
8149\= Expect no match
8150    D
8151No match, mark = B
8152
8153/(*MARK:A)(*THEN:B)(C|X)/mark,no_start_optimize
8154    C
8155 0: C
8156 1: C
8157MK: B
8158\= Expect no match
8159    D
8160No match, mark = B
8161
8162/(*MARK:A)(*THEN:B)(C|X)/mark
8163    C
8164 0: C
8165 1: C
8166MK: B
8167\= Expect no match
8168    D
8169No match, mark = B
8170
8171# This should fail, as the skip causes a bump to offset 3 (the skip).
8172
8173/A(*MARK:A)A+(*SKIP)(B|Z) | AC/x,mark
8174\= Expect no match
8175    AAAC
8176No match, mark = A
8177
8178# Same
8179
8180/A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/x,mark
8181\= Expect no match
8182    AAAC
8183No match, mark = B
8184
8185/A(*:A)A+(*SKIP)(B|Z) | AC/x,mark
8186\= Expect no match
8187    AAAC
8188No match, mark = A
8189
8190# This should fail, as a null name is the same as no name.
8191
8192/A(*MARK:A)A+(*SKIP:)(B|Z) | AC/x,mark
8193\= Expect no match
8194    AAAC
8195No match, mark = A
8196
8197# A check on what happens after hitting a mark and them bumping along to
8198# something that does not even start. Perl reports tags after the failures
8199# here, though it does not when the individual letters are made into something
8200# more complicated.
8201
8202/A(*:A)B|XX(*:B)Y/mark
8203    AABC
8204 0: AB
8205MK: A
8206    XXYZ
8207 0: XXY
8208MK: B
8209\= Expect no match
8210    XAQQ
8211No match, mark = A
8212    XAQQXZZ
8213No match, mark = A
8214    AXQQQ
8215No match, mark = A
8216    AXXQQQ
8217No match, mark = B
8218
8219/^(A(*THEN:A)B|C(*THEN:B)D)/mark
8220    AB
8221 0: AB
8222 1: AB
8223MK: A
8224    CD
8225 0: CD
8226 1: CD
8227MK: B
8228\= Expect no match
8229    AC
8230No match, mark = A
8231    CB
8232No match, mark = B
8233
8234/^(A(*PRUNE:A)B|C(*PRUNE:B)D)/mark
8235    AB
8236 0: AB
8237 1: AB
8238MK: A
8239    CD
8240 0: CD
8241 1: CD
8242MK: B
8243\= Expect no match
8244    AC
8245No match, mark = A
8246    CB
8247No match, mark = B
8248
8249# An empty name does not pass back an empty string. It is the same as if no
8250# name were given.
8251
8252/^(A(*PRUNE:)B|C(*PRUNE:B)D)/mark
8253    AB
8254 0: AB
8255 1: AB
8256    CD
8257 0: CD
8258 1: CD
8259MK: B
8260
8261# PRUNE goes to next bumpalong; COMMIT does not.
8262
8263/A(*PRUNE:A)B/mark
8264    ACAB
8265 0: AB
8266MK: A
8267
8268# Mark names can be duplicated.
8269
8270/A(*:A)B|X(*:A)Y/mark
8271    AABC
8272 0: AB
8273MK: A
8274    XXYZ
8275 0: XY
8276MK: A
8277
8278/b(*:m)f|a(*:n)w/mark
8279    aw
8280 0: aw
8281MK: n
8282\= Expect no match
8283    abc
8284No match, mark = m
8285
8286/b(*:m)f|aw/mark
8287    abaw
8288 0: aw
8289\= Expect no match
8290    abc
8291No match, mark = m
8292    abax
8293No match, mark = m
8294
8295/A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/x,mark
8296    AAAC
8297 0: AAC
8298
8299/(?=a(*MARK:A)b)..x/mark
8300    abxy
8301 0: abx
8302MK: A
8303\= Expect no match
8304    abpq
8305No match
8306
8307/(?=a(*MARK:A)b)..(*:Y)x/mark
8308    abxy
8309 0: abx
8310MK: Y
8311\= Expect no match
8312    abpq
8313No match
8314
8315/(?=a(*PRUNE:A)b)..x/mark
8316    abxy
8317 0: abx
8318MK: A
8319\= Expect no match
8320    abpq
8321No match
8322
8323/(?=a(*PRUNE:A)b)..(*:Y)x/mark
8324    abxy
8325 0: abx
8326MK: Y
8327\= Expect no match
8328    abpq
8329No match
8330
8331/(?=a(*THEN:A)b)..x/mark
8332    abxy
8333 0: abx
8334MK: A
8335\= Expect no match
8336    abpq
8337No match
8338
8339/(?=a(*THEN:A)b)..(*:Y)x/mark
8340    abxy
8341 0: abx
8342MK: Y
8343\= Expect no match
8344    abpq
8345No match
8346
8347/(another)?(\1?)test/
8348    hello world test
8349 0: test
8350 1: <unset>
8351 2:
8352
8353/(another)?(\1+)test/
8354\= Expect no match
8355    hello world test
8356No match
8357
8358/(a(*COMMIT)b){0}a(?1)|aac/
8359    aac
8360 0: aac
8361
8362/((?:a?)*)*c/
8363    aac
8364 0: aac
8365 1:
8366
8367/((?>a?)*)*c/
8368    aac
8369 0: aac
8370 1:
8371
8372/(?>.*?a)(?<=ba)/
8373    aba
8374 0: ba
8375
8376/(?:.*?a)(?<=ba)/
8377    aba
8378 0: aba
8379
8380/(?>.*?a)b/s
8381    aab
8382 0: ab
8383
8384/(?>.*?a)b/
8385    aab
8386 0: ab
8387
8388/(?>^a)b/s
8389\= Expect no match
8390    aab
8391No match
8392
8393/(?>.*?)(?<=(abcd)|(wxyz))/
8394    alphabetabcd
8395 0:
8396 1: abcd
8397    endingwxyz
8398 0:
8399 1: <unset>
8400 2: wxyz
8401
8402/(?>.*)(?<=(abcd)|(wxyz))/
8403    alphabetabcd
8404 0: alphabetabcd
8405 1: abcd
8406    endingwxyz
8407 0: endingwxyz
8408 1: <unset>
8409 2: wxyz
8410
8411/(?>.*)foo/
8412\= Expect no match
8413    abcdfooxyz
8414No match
8415
8416/(?>.*?)foo/
8417    abcdfooxyz
8418 0: foo
8419
8420/(?:(a(*PRUNE)b)){0}(?:(?1)|ac)/
8421    ac
8422 0: ac
8423
8424/(?:(a(*SKIP)b)){0}(?:(?1)|ac)/
8425    ac
8426 0: ac
8427
8428/(?<=(*SKIP)ac)a/
8429\= Expect no match
8430    aa
8431No match
8432
8433/A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/x,mark
8434    AAAC
8435 0: AC
8436
8437/a(*SKIP:m)x|ac(*:n)(*SKIP:n)d|ac/mark
8438    acacd
8439 0: acd
8440MK: n
8441
8442/A(*SKIP:m)x|A(*SKIP:n)x|AB/mark
8443    AB
8444 0: AB
8445
8446/((*SKIP:r)d){0}a(*SKIP:m)x|ac(*:n)|ac/mark
8447    acacd
8448 0: ac
8449MK: n
8450
8451# Tests that try to figure out how Perl works. My hypothesis is that the first
8452# verb that is backtracked onto is the one that acts. This seems to be the case
8453# almost all the time, but there is one exception that is perhaps a bug.
8454
8455# This matches "aaaac"; each PRUNE advances one character until the subject no
8456# longer starts with 5 'a's.
8457
8458/aaaaa(*PRUNE)b|a+c/
8459    aaaaaac
8460 0: aaaac
8461
8462# Putting SKIP in front of PRUNE makes no difference, as it is never
8463# backtracked onto, whether or not it has a label.
8464
8465/aaaaa(*SKIP)(*PRUNE)b|a+c/
8466    aaaaaac
8467 0: aaaac
8468
8469/aaaaa(*SKIP:N)(*PRUNE)b|a+c/
8470    aaaaaac
8471 0: aaaac
8472
8473/aaaa(*:N)a(*SKIP:N)(*PRUNE)b|a+c/
8474    aaaaaac
8475 0: aaaac
8476
8477# Putting THEN in front makes no difference.
8478
8479/aaaaa(*THEN)(*PRUNE)b|a+c/
8480    aaaaaac
8481 0: aaaac
8482
8483# However, putting COMMIT in front of the prune changes it to "no match". I
8484# think this is inconsistent and possibly a bug. For the moment, running this
8485# test is moved out of the Perl-compatible file.
8486
8487/aaaaa(*COMMIT)(*PRUNE)b|a+c/
8488
8489# OK, lets play the same game again using SKIP instead of PRUNE.
8490
8491# This matches "ac" because SKIP forces the next match to start on the
8492# sixth "a".
8493
8494/aaaaa(*SKIP)b|a+c/
8495    aaaaaac
8496 0: ac
8497
8498# Putting PRUNE in front makes no difference.
8499
8500/aaaaa(*PRUNE)(*SKIP)b|a+c/
8501    aaaaaac
8502 0: ac
8503
8504# Putting THEN in front makes no difference.
8505
8506/aaaaa(*THEN)(*SKIP)b|a+c/
8507    aaaaaac
8508 0: ac
8509
8510# In this case, neither does COMMIT. This still matches "ac".
8511
8512/aaaaa(*COMMIT)(*SKIP)b|a+c/
8513    aaaaaac
8514 0: ac
8515
8516# This gives "no match", as expected.
8517
8518/aaaaa(*COMMIT)b|a+c/
8519\= Expect no match
8520    aaaaaac
8521No match
8522
8523# ---- Tests using THEN ----
8524
8525# This matches "aaaaaac", as expected.
8526
8527/aaaaa(*THEN)b|a+c/
8528    aaaaaac
8529 0: aaaaaac
8530
8531# Putting SKIP in front makes no difference.
8532
8533/aaaaa(*SKIP)(*THEN)b|a+c/
8534    aaaaaac
8535 0: aaaaaac
8536
8537# Putting PRUNE in front makes no difference.
8538
8539/aaaaa(*PRUNE)(*THEN)b|a+c/
8540    aaaaaac
8541 0: aaaaaac
8542
8543# Putting COMMIT in front makes no difference.
8544
8545/aaaaa(*COMMIT)(*THEN)b|a+c/
8546    aaaaaac
8547 0: aaaaaac
8548
8549# End of "priority" tests
8550
8551/aaaaa(*:m)(*PRUNE:m)(*SKIP:m)m|a+/
8552    aaaaaa
8553 0: a
8554
8555/aaaaa(*:m)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/
8556    aaaaaa
8557 0: a
8558
8559/aaaaa(*:n)(*PRUNE:m)(*SKIP:m)m|a+/
8560    aaaaaa
8561 0: aaaa
8562
8563/aaaaa(*:n)(*MARK:m)(*PRUNE)(*SKIP:m)m|a+/
8564    aaaaaa
8565 0: a
8566
8567/a(*MARK:A)aa(*PRUNE:A)a(*SKIP:A)b|a+c/
8568    aaaac
8569 0: aac
8570
8571/a(*MARK:A)aa(*MARK:A)a(*SKIP:A)b|a+c/
8572    aaaac
8573 0: ac
8574
8575/aaa(*PRUNE:A)a(*SKIP:A)b|a+c/
8576    aaaac
8577 0: aac
8578
8579/aaa(*MARK:A)a(*SKIP:A)b|a+c/
8580    aaaac
8581 0: ac
8582
8583/a(*:m)a(*COMMIT)(*SKIP:m)b|a+c/mark
8584    aaaaaac
8585 0: ac
8586
8587/.?(a|b(*THEN)c)/
8588    ba
8589 0: ba
8590 1: a
8591
8592/(a(*COMMIT)b)c|abd/
8593    abc
8594 0: abc
8595 1: ab
8596\= Expect no match
8597    abd
8598No match
8599
8600/(?=a(*COMMIT)b)abc|abd/
8601    abc
8602 0: abc
8603    abd
8604 0: abd
8605
8606/(?>a(*COMMIT)b)c|abd/
8607    abc
8608 0: abc
8609    abd
8610 0: abd
8611
8612/a(?=b(*COMMIT)c)[^d]|abd/
8613    abc
8614 0: ab
8615\= Expect no match
8616    abd
8617No match
8618
8619/a(?=bc).|abd/
8620    abd
8621 0: abd
8622    abc
8623 0: ab
8624
8625/a(?>b(*COMMIT)c)d|abd/
8626\= Expect no match
8627    abceabd
8628No match
8629
8630/a(?>bc)d|abd/
8631    abceabd
8632 0: abd
8633
8634/(?>a(*COMMIT)b)c|abd/
8635    abd
8636 0: abd
8637
8638/(?>a(*COMMIT)c)d|abd/
8639\= Expect no match
8640    abd
8641No match
8642
8643/((?=a(*COMMIT)b)ab|ac){0}(?:(?1)|a(c))/
8644    ac
8645 0: ac
8646 1: <unset>
8647 2: c
8648
8649# These tests were formerly in test 2, but changes in PCRE and Perl have
8650# made them compatible.
8651
8652/^(a)?(?(1)a|b)+$/
8653\= Expect no match
8654    a
8655No match
8656
8657/A(*PRUNE:A)A+(*SKIP:A)(B|Z) | AC/x,mark
8658\= Expect no match
8659    AAAC
8660No match, mark = A
8661
8662/^((abc|abcx)(*THEN)y|abcd)/
8663    abcd
8664 0: abcd
8665 1: abcd
8666\= Expect no match
8667    abcxy
8668No match
8669
8670/^((yes|no)(*THEN)(*F))?/
8671\= Expect no match
8672    yes
8673No match
8674
8675/(A (.*)   C? (*THEN)  | A D) (*FAIL)/x
8676\= Expect no match
8677    AbcdCBefgBhiBqz
8678No match
8679
8680/(A (.*)   C? (*THEN)  | A D) z/x
8681\= Expect no match
8682    AbcdCBefgBhiBqz
8683No match
8684
8685/(A (.*)   C? (*THEN)  | A D) \s* (*FAIL)/x
8686\= Expect no match
8687    AbcdCBefgBhiBqz
8688No match
8689
8690/(A (.*)   C? (*THEN)  | A D) \s* z/x
8691\= Expect no match
8692    AbcdCBefgBhiBqz
8693No match
8694
8695/(A (.*)   (?:C|) (*THEN)  | A D) (*FAIL)/x
8696\= Expect no match
8697    AbcdCBefgBhiBqz
8698No match
8699
8700/(A (.*)   (?:C|) (*THEN)  | A D) z/x
8701\= Expect no match
8702    AbcdCBefgBhiBqz
8703No match
8704
8705/(A (.*)   C{0,6} (*THEN)  | A D) (*FAIL)/x
8706\= Expect no match
8707    AbcdCBefgBhiBqz
8708No match
8709
8710/(A (.*)   C{0,6} (*THEN)  | A D) z/x
8711\= Expect no match
8712    AbcdCBefgBhiBqz
8713No match
8714
8715/(A (.*)   (CE){0,6} (*THEN)  | A D) (*FAIL)/x
8716\= Expect no match
8717    AbcdCEBefgBhiBqz
8718No match
8719
8720/(A (.*)   (CE){0,6} (*THEN)  | A D) z/x
8721\= Expect no match
8722    AbcdCEBefgBhiBqz
8723No match
8724
8725/(A (.*)   (CE*){0,6} (*THEN)  | A D) (*FAIL)/x
8726\= Expect no match
8727    AbcdCBefgBhiBqz
8728No match
8729
8730/(A (.*)   (CE*){0,6} (*THEN)  | A D) z/x
8731\= Expect no match
8732    AbcdCBefgBhiBqz
8733No match
8734
8735/(?=a(*COMMIT)b|ac)ac|ac/
8736\= Expect no match
8737    ac
8738No match
8739
8740/(?=a(*COMMIT)b|(ac)) ac | (a)c/x
8741\= Expect no match
8742    ac
8743No match
8744
8745# ----
8746
8747/(?(?!b(*THEN)a)bn|bnn)/
8748    bnn
8749 0: bn
8750
8751/(?!b(*SKIP)a)bn|bnn/
8752    bnn
8753 0: bn
8754
8755/(?(?!b(*SKIP)a)bn|bnn)/
8756    bnn
8757 0: bn
8758
8759/(?!b(*PRUNE)a)bn|bnn/
8760    bnn
8761 0: bn
8762
8763/(?(?!b(*PRUNE)a)bn|bnn)/
8764    bnn
8765 0: bn
8766
8767/(?!b(*COMMIT)a)bn|bnn/
8768    bnn
8769 0: bn
8770
8771/(?(?!b(*COMMIT)a)bn|bnn)/
8772   bnn
8773 0: bn
8774
8775/(?=b(*SKIP)a)bn|bnn/
8776\= Expect no match
8777    bnn
8778No match
8779
8780/(?=b(*THEN)a)bn|bnn/
8781    bnn
8782 0: bnn
8783
8784/^(?!a(*SKIP)b)/
8785    ac
8786 0:
8787
8788/^(?!a(*SKIP)b)../
8789    acd
8790 0: ac
8791
8792/(?!a(*SKIP)b)../
8793    acd
8794 0: ac
8795
8796/^(?(?!a(*SKIP)b))/
8797    ac
8798 0:
8799
8800/^(?!a(*PRUNE)b)../
8801    acd
8802 0: ac
8803
8804/(?!a(*PRUNE)b)../
8805    acd
8806 0: ac
8807
8808/(?!a(*COMMIT)b)ac|cd/
8809    ac
8810 0: ac
8811
8812/\A.*?(?:a|bc)/
8813    ba
8814 0: ba
8815
8816/^(A(*THEN)B|C(*THEN)D)/
8817    CD
8818 0: CD
8819 1: CD
8820
8821/(*:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
8822    abc
8823 0: b
8824MK: m(m
8825
8826/(*PRUNE:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
8827    abc
8828 0: b
8829MK: m(m
8830
8831/(*SKIP:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
8832    abc
8833 0: b
8834
8835/(*THEN:m(m)(?&y)(?(DEFINE)(?<y>b))/mark
8836    abc
8837 0: b
8838MK: m(m
8839
8840/^\d*\w{4}/
8841    1234
8842 0: 1234
8843\= Expect no match
8844    123
8845No match
8846
8847/^[^b]*\w{4}/
8848    aaaa
8849 0: aaaa
8850\= Expect no match
8851    aaa
8852No match
8853
8854/^[^b]*\w{4}/i
8855    aaaa
8856 0: aaaa
8857\= Expect no match
8858    aaa
8859No match
8860
8861/^a*\w{4}/
8862    aaaa
8863 0: aaaa
8864\= Expect no match
8865    aaa
8866No match
8867
8868/^a*\w{4}/i
8869    aaaa
8870 0: aaaa
8871\= Expect no match
8872    aaa
8873No match
8874
8875/(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
8876    foofoo
8877 0: foofoo
8878 1: foo
8879    barbar
8880 0: barbar
8881 1: <unset>
8882 2: bar
8883
8884/(?<n>A)(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames
8885    AfooA
8886 0: AfooA
8887 1: A
8888 2: foo
8889    AbarA
8890 0: AbarA
8891 1: A
8892 2: <unset>
8893 3: bar
8894\= Expect no match
8895    Afoofoo
8896No match
8897    Abarbar
8898No match
8899
8900/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
8901    1 IN SOA non-sp1 non-sp2(
8902 0: 1 IN SOA non-sp1 non-sp2(
8903 1: 1
8904 2: non-sp1
8905 3: non-sp2
8906
8907/^ (?:(?<A>A)|(?'B'B)(?<A>A)) (?('A')x) (?(<B>)y)$/x,dupnames
8908    Ax
8909 0: Ax
8910 1: A
8911    BAxy
8912 0: BAxy
8913 1: <unset>
8914 2: B
8915 3: A
8916
8917/^A\xZ/
8918    A\0Z
8919 0: A\x00Z
8920
8921/^A\o{123}B/
8922    A\123B
8923 0: ASB
8924
8925/ ^ a + + b $ /x
8926    aaaab
8927 0: aaaab
8928
8929/ ^ a + #comment
8930  + b $ /x
8931    aaaab
8932 0: aaaab
8933
8934/ ^ a + #comment
8935  #comment
8936  + b $ /x
8937    aaaab
8938 0: aaaab
8939
8940/ ^ (?> a + ) b $ /x
8941    aaaab
8942 0: aaaab
8943
8944/ ^ ( a + ) + + \w $ /x
8945    aaaab
8946 0: aaaab
8947 1: aaaa
8948
8949/(?:a\Kb)*+/aftertext
8950    ababc
8951 0: b
8952 0+ c
8953
8954/(?>a\Kb)*/aftertext
8955    ababc
8956 0: b
8957 0+ c
8958
8959/(?:a\Kb)*/aftertext
8960    ababc
8961 0: b
8962 0+ c
8963
8964/(a\Kb)*+/aftertext
8965    ababc
8966 0: b
8967 0+ c
8968 1: ab
8969
8970/(a\Kb)*/aftertext
8971    ababc
8972 0: b
8973 0+ c
8974 1: ab
8975
8976/(?:x|(?:(xx|yy)+|x|x|x|x|x)|a|a|a)bc/
8977\= Expect no match
8978    acb
8979No match
8980
8981/\A(?:[^\"]++|\"(?:[^\"]*+|\"\")*+\")++/
8982    NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
8983 0: NON QUOTED "QUOT""ED" AFTER
8984
8985/\A(?:[^\"]++|\"(?:[^\"]++|\"\")*+\")++/
8986    NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
8987 0: NON QUOTED "QUOT""ED" AFTER
8988
8989/\A(?:[^\"]++|\"(?:[^\"]++|\"\")++\")++/
8990    NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
8991 0: NON QUOTED "QUOT""ED" AFTER
8992
8993/\A([^\"1]++|[\"2]([^\"3]*+|[\"4][\"5])*+[\"6])++/
8994    NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
8995 0: NON QUOTED "QUOT""ED" AFTER
8996 1:  AFTER
8997 2:
8998
8999/^\w+(?>\s*)(?<=\w)/
9000    test test
9001 0: tes
9002
9003/(?P<same>a)(?P<same>b)/g,dupnames
9004    abbaba
9005 0: ab
9006 1: a
9007 2: b
9008 0: ab
9009 1: a
9010 2: b
9011
9012/(?P<same>a)(?P<same>b)(?P=same)/g,dupnames
9013    abbaba
9014 0: aba
9015 1: a
9016 2: b
9017
9018/(?P=same)?(?P<same>a)(?P<same>b)/g,dupnames
9019    abbaba
9020 0: ab
9021 1: a
9022 2: b
9023 0: ab
9024 1: a
9025 2: b
9026
9027/(?:(?P=same)?(?:(?P<same>a)|(?P<same>b))(?P=same))+/g,dupnames
9028    bbbaaabaabb
9029 0: bbbaaaba
9030 1: a
9031 2: b
9032 0: bb
9033 1: <unset>
9034 2: b
9035
9036/(?:(?P=same)?(?:(?P=same)(?P<same>a)(?P=same)|(?P=same)?(?P<same>b)(?P=same)){2}(?P=same)(?P<same>c)(?P=same)){2}(?P<same>z)?/g,dupnames
9037\= Expect no match
9038    bbbaaaccccaaabbbcc
9039No match
9040
9041/(?P<Name>a)?(?P<Name2>b)?(?(<Name>)c|d)*l/
9042    acl
9043 0: acl
9044 1: a
9045    bdl
9046 0: bdl
9047 1: <unset>
9048 2: b
9049    adl
9050 0: dl
9051    bcl
9052 0: l
9053
9054/\sabc/
9055    \x{0b}abc
9056 0: \x0babc
9057
9058/[\Qa]\E]+/
9059    aa]]
9060 0: aa]]
9061
9062/[\Q]a\E]+/
9063    aa]]
9064 0: aa]]
9065
9066/A((((((((a))))))))\8B/
9067    AaaB
9068 0: AaaB
9069 1: a
9070 2: a
9071 3: a
9072 4: a
9073 5: a
9074 6: a
9075 7: a
9076 8: a
9077
9078/A(((((((((a)))))))))\9B/
9079    AaaB
9080 0: AaaB
9081 1: a
9082 2: a
9083 3: a
9084 4: a
9085 5: a
9086 6: a
9087 7: a
9088 8: a
9089 9: a
9090
9091/A[\8\9]B/
9092    A8B
9093 0: A8B
9094    A9B
9095 0: A9B
9096
9097/(|ab)*?d/
9098   abd
9099 0: abd
9100 1: ab
9101   xyd
9102 0: d
9103
9104/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
9105    1234abcd
9106 0:
9107 1: <unset>
9108 2: <unset>
9109 3: <unset>
9110 4: <unset>
9111 5:
9112
9113/(\2|a)(\1)/
9114    aaa
9115 0: aa
9116 1: a
9117 2: a
9118
9119/(\2)(\1)/
9120
9121/Z*(|d*){216}/
9122
9123/(?1)(?#?'){8}(a)/
9124    baaaaaaaaac
9125 0: aaaaaaaaa
9126 1: a
9127
9128/((((((((((((x))))))))))))\12/
9129    xx
9130 0: xx
9131 1: x
9132 2: x
9133 3: x
9134 4: x
9135 5: x
9136 6: x
9137 7: x
9138 8: x
9139 9: x
914010: x
914111: x
914212: x
9143
9144/A[\8]B[\9]C/
9145    A8B9C
9146 0: A8B9C
9147
9148/(?1)()((((((\1++))\x85)+)|))/
9149    \x85\x85
9150 0: \x85\x85
9151 1:
9152 2: \x85\x85
9153 3: \x85\x85
9154 4: \x85\x85
9155 5: \x85
9156 6:
9157 7:
9158
9159/(?|(\k'Pm')|(?'Pm'))/
9160    abcd
9161 0:
9162 1:
9163
9164/(?|(aaa)|(b))\g{1}/
9165    aaaaaa
9166 0: aaaaaa
9167 1: aaa
9168    bb
9169 0: bb
9170 1: b
9171
9172/(?|(aaa)|(b))(?1)/
9173    aaaaaa
9174 0: aaaaaa
9175 1: aaa
9176    baaa
9177 0: baaa
9178 1: b
9179\= Expect no match
9180    bb
9181No match
9182
9183/(?|(aaa)|(b))/
9184    xaaa
9185 0: aaa
9186 1: aaa
9187    xbc
9188 0: b
9189 1: b
9190
9191/(?|(?'a'aaa)|(?'a'b))\k'a'/
9192    aaaaaa
9193 0: aaaaaa
9194 1: aaa
9195    bb
9196 0: bb
9197 1: b
9198
9199/(?|(?'a'aaa)|(?'a'b))(?'a'cccc)\k'a'/dupnames
9200    aaaccccaaa
9201 0: aaaccccaaa
9202 1: aaa
9203 2: cccc
9204    bccccb
9205 0: bccccb
9206 1: b
9207 2: cccc
9208
9209# /x does not apply to MARK labels
9210
9211/x (*MARK:ab cd # comment
9212ef) x/x,mark
9213    axxz
9214 0: xx
9215MK: ab cd # comment\x0aef
9216
9217/(?<=a(B){0}c)X/
9218    acX
9219 0: X
9220
9221/(?<DEFINE>b)(?(DEFINE)(a+))(?&DEFINE)/
9222    bbbb
9223 0: bb
9224 1: b
9225\= Expect no match
9226    baaab
9227No match
9228
9229/(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[,;:])(?=.{8,16})(?!.*[\s])/
9230    \   Fred:099
9231 0:
9232
9233/(?=.*X)X$/
9234    \  X
9235 0: X
9236
9237/(?s)(?=.*?)b/
9238    aabc
9239 0: b
9240
9241/(Z)(a)\2{1,2}?(?-i)\1X/i
9242    ZaAAZX
9243 0: ZaAAZX
9244 1: Z
9245 2: a
9246
9247/(?'c')XX(?'YYYYYYYYYYYYYYYYYYYYYYYCl')/
9248
9249/[s[:digit:]\E-H]+/
9250    s09-H
9251 0: s09-H
9252
9253/[s[:digit:]\Q\E-H]+/
9254    s09-H
9255 0: s09-H
9256
9257/a+(?:|b)a/
9258    aaaa
9259 0: aaaa
9260
9261/X?(R||){3335}/
9262
9263/(?1)(A(*COMMIT)|B)D/
9264    ABD
9265 0: ABD
9266 1: B
9267    XABD
9268 0: ABD
9269 1: B
9270    BAD
9271 0: BAD
9272 1: A
9273    ABXABD
9274 0: ABD
9275 1: B
9276\= Expect no match
9277    ABX
9278No match
9279
9280/(?(DEFINE)(?<m> 1? (?=(?<cond>2)?) 1 2 (?('cond')|3)))
9281    \A
9282    ()
9283    (?&m)
9284    \Z/x
9285    123
9286 0: 123
9287 1: <unset>
9288 2: <unset>
9289 3:
9290
9291/^(?:
9292(?: A| (1? (?=(?<cond>2)?) (1) 2 (?('cond')|3)) )
9293(Z)
9294)+$/x
9295    AZ123Z
9296 0: AZ123Z
9297 1: 123
9298 2: <unset>
9299 3: 1
9300 4: Z
9301\= Expect no match
9302    AZ12Z
9303No match
9304
9305/^ (?(DEFINE) ( (?!(a)\2b)..) )   ()(?1)  /x
9306    acb
9307 0: ac
9308 1: <unset>
9309 2: <unset>
9310 3:
9311\= Expect no match
9312    aab
9313No match
9314
9315/(?>ab|abab){1,5}?M/
9316    abababababababababababM
9317 0: abababababM
9318
9319/(?>ab|abab){2}?M/
9320    abababM
9321 0: ababM
9322
9323/((?(?=(a))a)+k)/
9324    bbak
9325 0: ak
9326 1: ak
9327 2: a
9328
9329/((?(?=(a))a|)+k)/
9330    bbak
9331 0: ak
9332 1: ak
9333 2: a
9334
9335/(?(?!(b))a|b)+k/
9336    ababbalbbadabak
9337 0: abak
9338 1: b
9339
9340/(?!(b))c|b/
9341    Ab
9342 0: b
9343    Ac
9344 0: c
9345
9346/(?=(b))b|c/
9347    Ab
9348 0: b
9349 1: b
9350    Ac
9351 0: c
9352
9353/^(.|(.)(?1)\2)$/
9354    a
9355 0: a
9356 1: a
9357    aba
9358 0: aba
9359 1: aba
9360 2: a
9361    abcba
9362 0: abcba
9363 1: abcba
9364 2: a
9365    ababa
9366 0: ababa
9367 1: ababa
9368 2: a
9369    abcdcba
9370 0: abcdcba
9371 1: abcdcba
9372 2: a
9373
9374/^((.)(?1)\2|.?)$/
9375    a
9376 0: a
9377 1: a
9378    aba
9379 0: aba
9380 1: aba
9381 2: a
9382    abba
9383 0: abba
9384 1: abba
9385 2: a
9386    abcba
9387 0: abcba
9388 1: abcba
9389 2: a
9390    ababa
9391 0: ababa
9392 1: ababa
9393 2: a
9394    abccba
9395 0: abccba
9396 1: abccba
9397 2: a
9398    abcdcba
9399 0: abcdcba
9400 1: abcdcba
9401 2: a
9402    abcddcba
9403 0: abcddcba
9404 1: abcddcba
9405 2: a
9406
9407/^(.)(\1|a(?2))/
9408    bab
9409 0: bab
9410 1: b
9411 2: ab
9412
9413/^(.|(.)(?1)?\2)$/
9414    abcba
9415 0: abcba
9416 1: abcba
9417 2: a
9418
9419/^(?(?=(a))abc|def)/
9420    abc
9421 0: abc
9422 1: a
9423
9424/^(?(?!(a))def|abc)/
9425    abc
9426 0: abc
9427 1: a
9428
9429/^(?(?=(a)(*ACCEPT))abc|def)/
9430    abc
9431 0: abc
9432 1: a
9433
9434/^(?(?!(a)(*ACCEPT))def|abc)/
9435    abc
9436 0: abc
9437 1: a
9438
9439/^(?1)\d{3}(a)/
9440    a123a
9441 0: a123a
9442 1: a
9443
9444# This pattern uses a lot of named subpatterns in order to match email
9445# addresses in various formats. It's a heavy test for named subpatterns. In the
9446# <atext> group, slash is coded as \x{2f} so that this pattern can also be
9447# processed by perltest.sh, which does not cater for an escaped delimiter
9448# within the pattern. $ within the pattern must also be escaped. All $ and @
9449# characters in subject strings are escaped so that Perl doesn't interpret them
9450# as variable insertions and " characters must also be escaped for Perl.
9451
9452# This set of subpatterns is more or less a direct transliteration of the BNF
9453# definitions in RFC2822, without any of the obsolete features. The addition of
9454# a possessive + to the definition of <phrase> reduced the match limit in PCRE2
9455# from over 5 million to just under 400, and eliminated a very noticeable delay
9456# when this file was passed to perltest.sh.
9457
9458/(?ix)(?(DEFINE)
9459(?<addr_spec>       (?&local_part) \@ (?&domain) )
9460(?<angle_addr>      (?&CFWS)?+ < (?&addr_spec) > (?&CFWS)?+ )
9461(?<atext>           [a-z\d!#\$%&'*+-\x{2f}=?^_`{|}~] )
9462(?<atom>            (?&CFWS)?+ (?&atext)+ (?&CFWS)?+ )
9463(?<ccontent>        (?&ctext) | (?&quoted_pair) | (?&comment) )
9464(?<ctext>           [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ ()\\] )
9465(?<comment>         \( (?: (?&FWS)?+ (?&ccontent) )*+ (?&FWS)?+ \) )
9466(?<CFWS>            (?: (?&FWS)?+ (?&comment) )* (?# NOT possessive)
9467                    (?: (?&FWS)?+ (?&comment) | (?&FWS) ) )
9468(?<dcontent>        (?&dtext) | (?&quoted_pair) )
9469(?<display_name>    (?&phrase) )
9470(?<domain>          (?&dot_atom) | (?&domain_literal) )
9471(?<domain_literal>  (?&CFWS)?+ \[ (?: (?&FWS)?+ (?&dcontent) )* (?&FWS)?+ \]
9472                    (?&CFWS)?+ )
9473(?<dot_atom>        (?&CFWS)?+ (?&dot_atom_text) (?&CFWS)?+ )
9474(?<dot_atom_text>   (?&atext)++ (?: \. (?&atext)++)*+ )
9475(?<dtext>           [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ \[\]\\] )
9476(?<FWS>             (?: [\t\ ]*+ \n)?+ [\t\ ]++ )
9477(?<local_part>      (?&dot_atom) | (?&quoted_string)  )
9478(?<mailbox>         (?&name_addr) | (?&addr_spec) )
9479(?<name_addr>       (?&display_name)? (?&angle_addr) )
9480(?<phrase>          (?&word)++ )
9481(?<qcontent>        (?&qtext) | (?&quoted_pair) )
9482(?<quoted_pair>     " (?&text) )
9483(?<quoted_string>   (?&CFWS)?+ " (?: (?&FWS)?+ (?&qcontent))* (?&FWS)?+ "
9484                    (?&CFWS)?+ )
9485(?<qtext>           [^\x{9}\x{10}\x{13}\x{7f}-\x{ff}\ "\\] )
9486(?<text>            [^\r\n] )
9487(?<word>            (?&atom) | (?&quoted_string) )
9488) # End DEFINE
9489^(?&mailbox)$/
9490    Alan Other <user\@dom.ain>
9491 0: Alan Other <user@dom.ain>
9492    <user\@dom.ain>
9493 0: <user@dom.ain>
9494    user\@dom.ain
9495 0: user@dom.ain
9496    user\@[]
9497 0: user@[]
9498    user\@[domain literal]
9499 0: user@[domain literal]
9500    user\@[domain literal with \"[square brackets\"] inside]
9501 0: user@[domain literal with "[square brackets"] inside]
9502    \"A. Other\" <user.1234\@dom.ain> (a comment)
9503 0: "A. Other" <user.1234@dom.ain> (a comment)
9504    A. Other <user.1234\@dom.ain> (a comment)
9505 0: A. Other <user.1234@dom.ain> (a comment)
9506    \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
9507 0: "/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/"@x400-re.lay
9508\= Expect no match
9509    A missing angle <user\@some.where
9510No match
9511    The quick brown fox
9512No match
9513
9514# --------------------------------------------------------------------------
9515
9516# This pattern uses named groups to match default PCRE2 patterns. It's another
9517# heavy test for named subpatterns. Once again, code slash as \x{2f} and escape
9518# $ even in classes so that this works with pcre2test.
9519
9520/(?sx)(?(DEFINE)
9521
9522(?<assertion>         (?&simple_assertion) | (?&lookaround) )
9523
9524(?<atomic_group>      \( \? > (?&regex) \) )
9525
9526(?<back_reference>    \\ \d+ |
9527                      \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) |
9528                      \\k <(?&groupname)> |
9529                      \\k '(?&groupname)' |
9530                      \\k \{ (?&groupname) \} |
9531                      \( \? P= (?&groupname) \) )
9532
9533(?<branch>            (?:(?&assertion) |
9534                         (?&callout) |
9535                         (?&comment) |
9536                         (?&option_setting) |
9537                         (?&qualified_item) |
9538                         (?&quoted_string) |
9539                         (?&quoted_string_empty) |
9540                         (?&special_escape) |
9541                         (?&verb)
9542                      )* )
9543
9544(?<callout>           \(\?C (?: \d+ |
9545                      (?: (?<D>["'`^%\#\$])
9546                        (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' |
9547                      \{ (?: \}\} | [^}]*+ )* \} )
9548                      )? \) )
9549
9550(?<capturing_group>   \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )?
9551                      (?&regex) \) )
9552
9553(?<character_class>   \[ \^?+ (?: \] (?&class_item)* | (?&class_item)+ ) \] )
9554
9555(?<character_type>    (?! \\N\{\w+\} ) \\ [dDsSwWhHvVRN] )
9556
9557(?<class_item>        (?: \[ : (?:
9558                      alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|
9559                      punct|space|upper|word|xdigit
9560                      ) : \] |
9561                      (?&quoted_string) |
9562                      (?&quoted_string_empty) |
9563                      (?&escaped_character) |
9564                      (?&character_type) |
9565                      [^]] ) )
9566
9567(?<comment>           \(\?\# [^)]* \) | (?&quoted_string_empty) | \\E )
9568
9569(?<condition>         (?: \( [+-]? \d+ \) |
9570                          \( < (?&groupname) > \) |
9571                          \( ' (?&groupname) ' \) |
9572                          \( R \d* \) |
9573                          \( R & (?&groupname) \) |
9574                          \( (?&groupname) \) |
9575                          \( DEFINE \) |
9576                          \( VERSION >?=\d+(?:\.\d\d?)? \) |
9577                          (?&callout)?+ (?&comment)* (?&lookaround) ) )
9578
9579(?<conditional_group> \(\? (?&condition) (?&branch) (?: \| (?&branch) )? \) )
9580
9581(?<delimited_regex>   (?<delimiter> [-\x{2f}!"'`=_:;,%&@~]) (?&regex)
9582                      \k'delimiter' .* )
9583
9584(?<escaped_character> \\ (?: 0[0-7]{1,2} | [0-7]{1,3} | o\{ [0-7]+ \} |
9585                      x \{ (*COMMIT) [[:xdigit:]]* \} | x [[:xdigit:]]{0,2} |
9586                      [aefnrt] | c[[:print:]] |
9587                      [^[:alnum:]] ) )
9588
9589(?<group>             (?&capturing_group) | (?&non_capturing_group) |
9590                      (?&resetting_group) | (?&atomic_group) |
9591                      (?&conditional_group) )
9592
9593(?<groupname>         [a-zA-Z_]\w* )
9594
9595(?<literal_character> (?! (?&range_qualifier) ) [^[()|*+?.\$\\] )
9596
9597(?<lookaround>        \(\? (?: = | ! | <= | <! ) (?&regex) \) )
9598
9599(?<non_capturing_group> \(\? [iJmnsUx-]* : (?&regex) \) )
9600
9601(?<option_setting>    \(\? [iJmnsUx-]* \) )
9602
9603(?<qualified_item>    (?:\. |
9604                         (?&lookaround) |
9605                         (?&back_reference) |
9606                         (?&character_class) |
9607                         (?&character_type) |
9608                         (?&escaped_character) |
9609                         (?&group) |
9610                         (?&subroutine_call) |
9611                         (?&literal_character) |
9612                         (?&quoted_string)
9613                      ) (?&comment)? (?&qualifier)? )
9614
9615(?<qualifier>         (?: [?*+] | (?&range_qualifier) ) [+?]? )
9616
9617(?<quoted_string>     (?: \\Q (?: (?!\\E | \k'delimiter') . )++ (?: \\E | ) ) )
9618
9619(?<quoted_string_empty>  \\Q\\E )
9620
9621(?<range_qualifier>   \{ (?: \d+ (?: , \d* )? | , \d+ ) \} )
9622
9623(?<regex>             (?&start_item)* (?&branch) (?: \| (?&branch) )* )
9624
9625(?<resetting_group>   \( \? \| (?&regex) \) )
9626
9627(?<simple_assertion>  \^ | \$ | \\A | \\b | \\B | \\G | \\z | \\Z )
9628
9629(?<special_escape>    \\K )
9630
9631(?<start_item>        \( \* (?:
9632                      ANY |
9633                      ANYCRLF |
9634                      BSR_ANYCRLF |
9635                      BSR_UNICODE |
9636                      CR |
9637                      CRLF |
9638                      LF |
9639                      LIMIT_MATCH=\d+ |
9640                      LIMIT_DEPTH=\d+ |
9641                      LIMIT_HEAP=\d+ |
9642                      NOTEMPTY |
9643                      NOTEMPTY_ATSTART |
9644                      NO_AUTO_POSSESS |
9645                      NO_DOTSTAR_ANCHOR |
9646                      NO_JIT |
9647                      NO_START_OPT |
9648                      NUL |
9649                      UTF |
9650                      UCP ) \) )
9651
9652(?<subroutine_call>   (?: \(\?R\) | \(\?[+-]?\d+\) |
9653                      \(\? (?: & | P> ) (?&groupname) \) |
9654                      \\g < (?&groupname) > |
9655                      \\g ' (?&groupname) ' |
9656                      \\g < [+-]? \d+ > |
9657                      \\g ' [+-]? \d+ ) )
9658
9659(?<verb>              \(\* (?: ACCEPT | FAIL | F | COMMIT |
9660                      (?:MARK)?:(?&verbname) |
9661                      (?:PRUNE|SKIP|THEN) (?: : (?&verbname)? )? ) \) )
9662
9663(?<verbname>          [^)]+ )
9664
9665) # End DEFINE
9666# Kick it all off...
9667^(?&delimited_regex)$/subject_literal,jitstack=256
9668    /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
9669 0: /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
9670    /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
9671 0: /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
9672    /^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]/
9673 0: /^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]/
9674    /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
9675 0: /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
9676    /<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>/is
9677 0: /<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>/is
9678    /^(?(DEFINE) (?<A> a) (?<B> b) )  (?&A) (?&B) /
9679 0: /^(?(DEFINE) (?<A> a) (?<B> b) )  (?&A) (?&B) /
9680    /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
9681 0: /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
9682    /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
9683 0: /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
9684    /^(\w++|\s++)*$/
9685 0: /^(\w++|\s++)*$/
9686    /a+b?(*THEN)c+(*FAIL)/
9687 0: /a+b?(*THEN)c+(*FAIL)/
9688    /(A (A|B(*ACCEPT)|C) D)(E)/x
9689 0: /(A (A|B(*ACCEPT)|C) D)(E)/x
9690    /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
9691 0: /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
9692    /A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/B
9693 0: /A(*PRUNE)B(*SKIP)C(*THEN)D(*COMMIT)E(*F)F(*FAIL)G(?!)H(*ACCEPT)I/B
9694    /(?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
9695 0: /(?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
9696    /(?sx)(?(DEFINE)(?<assertion> (?&simple_assertion) | (?&lookaround) )(?<atomic_group> \( \? > (?&regex) \) )(?<back_reference> \\ \d+ | \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) | \\k <(?&groupname)> | \\k '(?&groupname)' | \\k \{ (?&groupname) \} | \( \? P= (?&groupname) \) )(?<branch> (?:(?&assertion) | (?&callout) | (?&comment) | (?&option_setting) | (?&qualified_item) | (?&quoted_string) | (?&quoted_string_empty) | (?&special_escape) | (?&verb) )* )(?<callout> \(\?C (?: \d+ | (?: (?<D>["'`^%\#\$]) (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' | \{ (?: \}\} | [^}]*+ )* \} ) )? \) )(?<capturing_group> \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )? (?&regex) \) )(?<character_class> \[ \^?+ (?: \] (?&class_item)* | (?&class_item)+ ) \] )(?<character_type> (?! \\N\{\w+\} ) \\ [dDsSwWhHvVRN] )(?<class_item> (?: \[ : (?: alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print| punct|space|upper|word|xdigit ) : \] | (?&quoted_string) | (?&quoted_string_empty) | (?&escaped_character) | (?&character_type) | [^]] ) )(?<comment> \(\?\# [^)]* \) | (?&quoted_string_empty) | \\E )(?<condition> (?: \( [+-]? \d+ \) | \( < (?&groupname) > \) | \( ' (?&groupname) ' \) | \( R \d* \) | \( R & (?&groupname) \) | \( (?&groupname) \) | \( DEFINE \) | \( VERSION >?=\d+(?:\.\d\d?)? \) | (?&callout)?+ (?&comment)* (?&lookaround) ) )(?<conditional_group> \(\? (?&condition) (?&branch) (?: \| (?&branch) )? \) )(?<delimited_regex> (?<delimiter> [-\x{2f}!"'`=_:;,%&@~]) (?&regex) \k'delimiter' .* )(?<escaped_character> \\ (?: 0[0-7]{1,2} | [0-7]{1,3} | o\{ [0-7]+ \} | x \{ (*COMMIT) [[:xdigit:]]* \} | x [[:xdigit:]]{0,2} | [aefnrt] | c[[:print:]] | [^[:alnum:]] ) )(?<group> (?&capturing_group) | (?&non_capturing_group) | (?&resetting_group) | (?&atomic_group) | (?&conditional_group) )(?<groupname> [a-zA-Z_]\w* )(?<literal_character> (?! (?&range_qualifier) ) [^[()|*+?.\$\\] )(?<lookaround> \(\? (?: = | ! | <= | <! ) (?&regex) \) )(?<non_capturing_group> \(\? [iJmnsUx-]* : (?&regex) \) )(?<option_setting> \(\? [iJmnsUx-]* \) )(?<qualified_item> (?:\. | (?&lookaround) | (?&back_reference) | (?&character_class) | (?&character_type) | (?&escaped_character) | (?&group) | (?&subroutine_call) | (?&literal_character) | (?&quoted_string) ) (?&comment)? (?&qualifier)? )(?<qualifier> (?: [?*+] | (?&range_qualifier) ) [+?]? )(?<quoted_string> (?: \\Q (?: (?!\\E | \k'delimiter') . )++ (?: \\E | ) ) ) (?<quoted_string_empty> \\Q\\E ) (?<range_qualifier> \{ (?: \d+ (?: , \d* )? | , \d+ ) \} )(?<regex> (?&start_item)* (?&branch) (?: \| (?&branch) )* )(?<resetting_group> \( \? \| (?&regex) \) )(?<simple_assertion> \^ | \$ | \\A | \\b | \\B | \\G | \\z | \\Z )(?<special_escape> \\K )(?<start_item> \( \* (?: ANY | ANYCRLF | BSR_ANYCRLF | BSR_UNICODE | CR | CRLF | LF | LIMIT_MATCH=\d+ | LIMIT_DEPTH=\d+ | LIMIT_HEAP=\d+ | NOTEMPTY | NOTEMPTY_ATSTART | NO_AUTO_POSSESS | NO_DOTSTAR_ANCHOR | NO_JIT | NO_START_OPT | NUL | UTF | UCP ) \) )(?<subroutine_call> (?: \(\?R\) | \(\?[+-]?\d+\) | \(\? (?: & | P> ) (?&groupname) \) | \\g < (?&groupname) > | \\g ' (?&groupname) ' | \\g < [+-]? \d+ > | \\g ' [+-]? \d+ ) )(?<verb> \(\* (?: ACCEPT | FAIL | F | COMMIT | (?:MARK)?:(?&verbname) | (?:PRUNE|SKIP|THEN) (?: : (?&verbname)? )? ) \) )(?<verbname> [^)]+ ))^(?&delimited_regex)$/
9697 0: /(?sx)(?(DEFINE)(?<assertion> (?&simple_assertion) | (?&lookaround) )(?<atomic_group> \( \? > (?&regex) \) )(?<back_reference> \\ \d+ | \\g (?: [+-]?\d+ | \{ (?: [+-]?\d+ | (?&groupname) ) \} ) | \\k <(?&groupname)> | \\k '(?&groupname)' | \\k \{ (?&groupname) \} | \( \? P= (?&groupname) \) )(?<branch> (?:(?&assertion) | (?&callout) | (?&comment) | (?&option_setting) | (?&qualified_item) | (?&quoted_string) | (?&quoted_string_empty) | (?&special_escape) | (?&verb) )* )(?<callout> \(\?C (?: \d+ | (?: (?<D>["'`^%\#\$]) (?: \k'D'\k'D' | (?!\k'D') . )* \k'D' | \{ (?: \}\} | [^}]*+ )* \} ) )? \) )(?<capturing_group> \( (?: \? P? < (?&groupname) > | \? ' (?&groupname) ' )? (?&regex) \) )(?<character_class> \[ \^?+ (?: \] (?&class_item)* | (?&class_item)+ ) \] )(?<character_type> (?! \\N\{\w+\} ) \\ [dDsSwWhHvVRN] )(?<class_item> (?: \[ : (?: alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print| punct|space|upper|word|xdigit ) : \] | (?&quoted_string) | (?&quoted_string_empty) | (?&escaped_character) | (?&character_type) | [^]] ) )(?<comment> \(\?\# [^)]* \) | (?&quoted_string_empty) | \\E )(?<condition> (?: \( [+-]? \d+ \) | \( < (?&groupname) > \) | \( ' (?&groupname) ' \) | \( R \d* \) | \( R & (?&groupname) \) | \( (?&groupname) \) | \( DEFINE \) | \( VERSION >?=\d+(?:\.\d\d?)? \) | (?&callout)?+ (?&comment)* (?&lookaround) ) )(?<conditional_group> \(\? (?&condition) (?&branch) (?: \| (?&branch) )? \) )(?<delimited_regex> (?<delimiter> [-\x{2f}!"'`=_:;,%&@~]) (?&regex) \k'delimiter' .* )(?<escaped_character> \\ (?: 0[0-7]{1,2} | [0-7]{1,3} | o\{ [0-7]+ \} | x \{ (*COMMIT) [[:xdigit:]]* \} | x [[:xdigit:]]{0,2} | [aefnrt] | c[[:print:]] | [^[:alnum:]] ) )(?<group> (?&capturing_group) | (?&non_capturing_group) | (?&resetting_group) | (?&atomic_group) | (?&conditional_group) )(?<groupname> [a-zA-Z_]\w* )(?<literal_character> (?! (?&range_qualifier) ) [^[()|*+?.\$\\] )(?<lookaround> \(\? (?: = | ! | <= | <! ) (?&regex) \) )(?<non_capturing_group> \(\? [iJmnsUx-]* : (?&regex) \) )(?<option_setting> \(\? [iJmnsUx-]* \) )(?<qualified_item> (?:\. | (?&lookaround) | (?&back_reference) | (?&character_class) | (?&character_type) | (?&escaped_character) | (?&group) | (?&subroutine_call) | (?&literal_character) | (?&quoted_string) ) (?&comment)? (?&qualifier)? )(?<qualifier> (?: [?*+] | (?&range_qualifier) ) [+?]? )(?<quoted_string> (?: \\Q (?: (?!\\E | \k'delimiter') . )++ (?: \\E | ) ) ) (?<quoted_string_empty> \\Q\\E ) (?<range_qualifier> \{ (?: \d+ (?: , \d* )? | , \d+ ) \} )(?<regex> (?&start_item)* (?&branch) (?: \| (?&branch) )* )(?<resetting_group> \( \? \| (?&regex) \) )(?<simple_assertion> \^ | \$ | \\A | \\b | \\B | \\G | \\z | \\Z )(?<special_escape> \\K )(?<start_item> \( \* (?: ANY | ANYCRLF | BSR_ANYCRLF | BSR_UNICODE | CR | CRLF | LF | LIMIT_MATCH=\d+ | LIMIT_DEPTH=\d+ | LIMIT_HEAP=\d+ | NOTEMPTY | NOTEMPTY_ATSTART | NO_AUTO_POSSESS | NO_DOTSTAR_ANCHOR | NO_JIT | NO_START_OPT | NUL | UTF | UCP ) \) )(?<subroutine_call> (?: \(\?R\) | \(\?[+-]?\d+\) | \(\? (?: & | P> ) (?&groupname) \) | \\g < (?&groupname) > | \\g ' (?&groupname) ' | \\g < [+-]? \d+ > | \\g ' [+-]? \d+ ) )(?<verb> \(\* (?: ACCEPT | FAIL | F | COMMIT | (?:MARK)?:(?&verbname) | (?:PRUNE|SKIP|THEN) (?: : (?&verbname)? )? ) \) )(?<verbname> [^)]+ ))^(?&delimited_regex)$/
9698\= Expect no match
9699    /((?(?C'')\QX\E(?!((?(?C'')(?!X=X));=)r*X=X));=)/
9700No match
9701    /(?:(?(2y)a|b)(X))+/
9702No match
9703    /a(*MARK)b/
9704No match
9705    /a(*CR)b/
9706No match
9707    /(?P<abn>(?P=abn)(?<badstufxxx)/
9708No match
9709
9710# --------------------------------------------------------------------------
9711
9712/<(?x:[a b])>/xx
9713    < >
9714 0: < >
9715
9716/<(?:[a b])>/xx
9717    < >
9718No match
9719
9720/<(?xxx:[a b])>/
9721    < >
9722No match
9723
9724/<(?-x:[a b])>/xx
9725    < >
9726 0: < >
9727
9728/[[:digit:]-]+/
9729    12-24
9730 0: 12-24
9731
9732/((?<=((*ACCEPT)) )\1?\b) /
9733\= Expect no match
9734    ((?<=((*ACCEPT)) )\\1?\\b)\x20
9735No match
9736
9737/((?<=((*ACCEPT))X)\1?Y)\1/
9738    XYYZ
9739 0: YY
9740 1: Y
9741 2:
9742
9743/((?<=((*ACCEPT))X)\1?Y(*ACCEPT))\1/
9744    XYYZ
9745 0: Y
9746 1: Y
9747 2:
9748
9749/(?(DEFINE)(?<optional_a>a?)X)^(?&optional_a)a$/
9750    aa
9751 0: aa
9752    a
9753 0: a
9754
9755/^(a?)b(?1)a/
9756    abaa
9757 0: abaa
9758 1: a
9759    aba
9760 0: aba
9761 1: a
9762    baa
9763 0: baa
9764 1:
9765    ba
9766 0: ba
9767 1:
9768
9769/^(a?)+b(?1)a/
9770    abaa
9771 0: abaa
9772 1:
9773    aba
9774 0: aba
9775 1:
9776    baa
9777 0: baa
9778 1:
9779    ba
9780 0: ba
9781 1:
9782
9783/^(a?)++b(?1)a/
9784    abaa
9785 0: abaa
9786 1:
9787    aba
9788 0: aba
9789 1:
9790    baa
9791 0: baa
9792 1:
9793    ba
9794 0: ba
9795 1:
9796
9797/^(a?)+b/
9798    b
9799 0: b
9800 1:
9801    ab
9802 0: ab
9803 1:
9804    aaab
9805 0: aaab
9806 1:
9807
9808/(?=a+)a(a+)++b/
9809    aab
9810 0: aab
9811 1: a
9812
9813/(?<=\G.)/g,aftertext
9814    abc
9815 0:
9816 0+ bc
9817 0:
9818 0+ c
9819 0:
9820 0+
9821
9822/(?<=(?=.)?)/
9823
9824/(?<=(?=.)?+)/
9825
9826/(?<=(?=.)*)/
9827
9828/(?<=(?=.){4,5})/
9829
9830/(?<=(?=.){4,5}x)/
9831
9832/a(?=.(*:X))(*SKIP:X)(*F)|(.)/
9833    abc
9834 0: a
9835 1: a
9836
9837/a(?>(*:X))(*SKIP:X)(*F)|(.)/
9838    abc
9839 0: a
9840 1: a
9841
9842/a(?:(*:X))(*SKIP:X)(*F)|(.)/
9843    abc
9844 0: b
9845 1: b
9846
9847#pattern no_start_optimize
9848
9849/(?>a(*:1))(?>b(*:1))(*SKIP:1)x|.*/
9850    abc
9851 0: abc
9852
9853/(?>a(*:1))(?>b)(*SKIP:1)x|.*/
9854    abc
9855 0: abc
9856
9857#subject mark
9858
9859/a(*ACCEPT:X)b/
9860    abc
9861 0: a
9862MK: X
9863
9864/(?=a(*ACCEPT:QQ)bc)axyz/
9865    axyz
9866 0: axyz
9867MK: QQ
9868
9869/(?(DEFINE)(a(*ACCEPT:X)))(?1)b/
9870    abc
9871 0: ab
9872MK: X
9873
9874/a(*F:X)b/
9875    abc
9876No match, mark = X
9877
9878/(?(DEFINE)(a(*F:X)))(?1)b/
9879    abc
9880No match, mark = X
9881
9882/a(*COMMIT:X)b/
9883    abc
9884 0: ab
9885MK: X
9886
9887/(?(DEFINE)(a(*COMMIT:X)))(?1)b/
9888    abc
9889 0: ab
9890MK: X
9891
9892/a+(*:Z)b(*COMMIT:X)(*SKIP:Z)c|.*/
9893    aaaabd
9894 0: bd
9895
9896/a+(*:Z)b(*COMMIT:X)(*SKIP:X)c|.*/
9897    aaaabd
9898No match, mark = X
9899
9900/a(*COMMIT:X)b/
9901    axabc
9902No match, mark = X
9903
9904#pattern -no_start_optimize
9905#subject -mark
9906
9907/(.COMMIT)(*COMMIT::::::::::interal error:::)/
9908
9909/(*COMMIT:��)/
9910
9911/(*COMMIT:]w)/
9912
9913/(?i)A(?^)B(?^x:C D)(?^i)e f/
9914    aBCDE F
9915 0: aBCDE F
9916\= Expect no match
9917    aBCDEF
9918No match
9919    AbCDe f
9920No match
9921
9922/(*pla:foo).{6}/
9923    abcfoobarxyz
9924 0: foobar
9925\= Expect no match
9926    abcfooba
9927No match
9928
9929/(*positive_lookahead:foo).{6}/
9930    abcfoobarxyz
9931 0: foobar
9932
9933/(?(*pla:foo).{6}|a..)/
9934    foobarbaz
9935 0: foobar
9936    abcfoobar
9937 0: abc
9938
9939/(?(*positive_lookahead:foo).{6}|a..)/
9940    foobarbaz
9941 0: foobar
9942    abcfoobar
9943 0: abc
9944
9945/(*plb:foo)bar/
9946    abcfoobar
9947 0: bar
9948\= Expect no match
9949    abcbarfoo
9950No match
9951
9952/(*positive_lookbehind:foo)bar/
9953    abcfoobar
9954 0: bar
9955\= Expect no match
9956    abcbarfoo
9957No match
9958
9959/(?(*plb:foo)bar|baz)/
9960    abcfoobar
9961 0: bar
9962    bazfoobar
9963 0: baz
9964    abcbazfoobar
9965 0: baz
9966    foobazfoobar
9967 0: bar
9968
9969/(?(*positive_lookbehind:foo)bar|baz)/
9970    abcfoobar
9971 0: bar
9972    bazfoobar
9973 0: baz
9974    abcbazfoobar
9975 0: baz
9976    foobazfoobar
9977 0: bar
9978
9979/(*nlb:foo)bar/
9980    abcbarfoo
9981 0: bar
9982\= Expect no match
9983    abcfoobar
9984No match
9985
9986/(*negative_lookbehind:foo)bar/
9987    abcbarfoo
9988 0: bar
9989\= Expect no match
9990    abcfoobar
9991No match
9992
9993/(?(*nlb:foo)bar|baz)/
9994    abcfoobaz
9995 0: baz
9996    abcbarbaz
9997 0: bar
9998\= Expect no match
9999    abcfoobar
10000No match
10001
10002/(?(*negative_lookbehind:foo)bar|baz)/
10003    abcfoobaz
10004 0: baz
10005    abcbarbaz
10006 0: bar
10007\= Expect no match
10008    abcfoobar
10009No match
10010
10011/(*atomic:a+)\w/
10012    aaab
10013 0: aaab
10014\= Expect no match
10015    aaaa
10016No match
10017
10018/   (?<word> \w+ )*    \.   /xi
10019    pokus.
10020 0: pokus.
10021 1: pokus
10022
10023/(?(DEFINE) (?<word> \w+ ) ) (?&word)*   \./xi
10024    pokus.
10025 0: pokus.
10026
10027/(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* )   \./xi
10028    pokus.
10029 0: pokus.
10030 1: <unset>
10031 2: pokus
10032
10033/(?&word)*  (?(DEFINE) (?<word> \w+ ) )  \./xi
10034    pokus.
10035 0: pokus.
10036
10037/(?&word)*  \. (?<word> \w+ )/xi
10038    pokus.hokus
10039 0: pokus.hokus
10040 1: hokus
10041
10042/a(?(?=(*:2)b).)/mark
10043    abc
10044 0: ab
10045MK: 2
10046    acb
10047 0: a
10048
10049/a(?(?!(*:2)b).)/mark
10050    acb
10051 0: ac
10052    abc
10053 0: a
10054MK: 2
10055
10056/(?:a|ab){1}+c/
10057\= Expect no match
10058    abc
10059No match
10060
10061/(a|ab){1}+c/
10062    abc
10063No match
10064
10065/(a+){1}+a/
10066\= Expect no match
10067    aaaa
10068No match
10069
10070/(?(DEFINE)(a|ab))(?1){1}+c/
10071    abc
10072No match
10073
10074/(?:a|(?=b)|.)*\z/
10075    abc
10076 0: abc
10077
10078/(?:a|(?=b)|.)*/
10079    abc
10080 0: a
10081
10082/(?<=a(*SKIP)x)|c/
10083    abcd
10084No match
10085
10086/(?<=a(*SKIP)x)|d/
10087    abcd
10088 0: d
10089
10090/(?<=(?=.(?<=x)))/aftertext
10091    abx
10092 0:
10093 0+ x
10094
10095/(?<=(?=(?<=a)))b/
10096    ab
10097 0: b
10098
10099/^(?<A>a)(?(<A>)b)((?<=b).*)$/
10100    abc
10101 0: abc
10102 1: a
10103 2: c
10104
10105/^(a\1?){4}$/
10106    aaaa
10107 0: aaaa
10108 1: a
10109    aaaaaa
10110 0: aaaaaa
10111 1: aa
10112
10113/^((\1+)|\d)+133X$/
10114    111133X
10115 0: 111133X
10116 1: 11
10117 2: 11
10118
10119/^(?=.*(?=(([A-Z]).*(?(1)\1)))(?!.+\2)){26}/i
10120    The quick brown fox jumps over the lazy dog.
10121 0:
10122 1: quick brown fox jumps over the lazy dog.
10123 2: q
10124    Jackdaws love my big sphinx of quartz.
10125 0:
10126 1: Jackdaws love my big sphinx of quartz.
10127 2: J
10128    Pack my box with five dozen liquor jugs.
10129 0:
10130 1: Pack my box with five dozen liquor jugs.
10131 2: P
10132\= Expect no match
10133    The quick brown fox jumps over the lazy cat.
10134No match
10135    Hackdaws love my big sphinx of quartz.
10136No match
10137    Pack my fox with five dozen liquor jugs.
10138No match
10139
10140/^(?>.*?([A-Z])(?!.*\1)){26}/i
10141    The quick brown fox jumps over the lazy dog.
10142 0: The quick brown fox jumps over the lazy dog
10143 1: g
10144    Jackdaws love my big sphinx of quartz.
10145 0: Jackdaws love my big sphinx of quartz
10146 1: z
10147    Pack my box with five dozen liquor jugs.
10148 0: Pack my box with five dozen liquor jugs
10149 1: s
10150\= Expect no match
10151    The quick brown fox jumps over the lazy cat.
10152No match
10153    Hackdaws love my big sphinx of quartz.
10154No match
10155    Pack my fox with five dozen liquor jugs.
10156No match
10157
10158/(?<=X(?(DEFINE)(A)))X(*F)/
10159\= Expect no match
10160    AXYZ
10161No match
10162
10163/(?<=X(?(DEFINE)(A)))./
10164    AXYZ
10165 0: Y
10166
10167/(?<=X(?(DEFINE)(.*))Y)./
10168    AXYZ
10169 0: Z
10170
10171/(?<=X(?(DEFINE)(Y))(?1))./
10172    AXYZ
10173 0: Z
10174
10175/(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word/
10176    word
10177 0: word
10178
10179# End of testinput1
10180