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