chiark / gitweb /
pcre3 (1:8.30-5) unstable; urgency=low
[pcre3.git] / testdata / testinput1
1 /-- This set of tests is for features that are compatible with all versions of
2     Perl >= 5.10, in non-UTF-8 mode. It should run clean for both the 8-bit and
3     16-bit PCRE libraries. --/
4
5 /the quick brown fox/
6     the quick brown fox
7     The quick brown FOX
8     What do you know about the quick brown fox?
9     What do you know about THE QUICK BROWN FOX?
10
11 /The quick brown fox/i
12     the quick brown fox
13     The quick brown FOX
14     What do you know about the quick brown fox?
15     What do you know about THE QUICK BROWN FOX?
16
17 /abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
18     abcd\t\n\r\f\a\e9;\$\\?caxyz
19
20 /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
21     abxyzpqrrrabbxyyyypqAzz
22     abxyzpqrrrabbxyyyypqAzz
23     aabxyzpqrrrabbxyyyypqAzz
24     aaabxyzpqrrrabbxyyyypqAzz
25     aaaabxyzpqrrrabbxyyyypqAzz
26     abcxyzpqrrrabbxyyyypqAzz
27     aabcxyzpqrrrabbxyyyypqAzz
28     aaabcxyzpqrrrabbxyyyypAzz
29     aaabcxyzpqrrrabbxyyyypqAzz
30     aaabcxyzpqrrrabbxyyyypqqAzz
31     aaabcxyzpqrrrabbxyyyypqqqAzz
32     aaabcxyzpqrrrabbxyyyypqqqqAzz
33     aaabcxyzpqrrrabbxyyyypqqqqqAzz
34     aaabcxyzpqrrrabbxyyyypqqqqqqAzz
35     aaaabcxyzpqrrrabbxyyyypqAzz
36     abxyzzpqrrrabbxyyyypqAzz
37     aabxyzzzpqrrrabbxyyyypqAzz
38     aaabxyzzzzpqrrrabbxyyyypqAzz
39     aaaabxyzzzzpqrrrabbxyyyypqAzz
40     abcxyzzpqrrrabbxyyyypqAzz
41     aabcxyzzzpqrrrabbxyyyypqAzz
42     aaabcxyzzzzpqrrrabbxyyyypqAzz
43     aaaabcxyzzzzpqrrrabbxyyyypqAzz
44     aaaabcxyzzzzpqrrrabbbxyyyypqAzz
45     aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
46     aaabcxyzpqrrrabbxyyyypABzz
47     aaabcxyzpqrrrabbxyyyypABBzz
48     >>>aaabxyzpqrrrabbxyyyypqAzz
49     >aaaabxyzpqrrrabbxyyyypqAzz
50     >>>>abcxyzpqrrrabbxyyyypqAzz
51     *** Failers
52     abxyzpqrrabbxyyyypqAzz
53     abxyzpqrrrrabbxyyyypqAzz
54     abxyzpqrrrabxyyyypqAzz
55     aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
56     aaaabcxyzzzzpqrrrabbbxyyypqAzz
57     aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
58
59 /^(abc){1,2}zz/
60     abczz
61     abcabczz
62     *** Failers
63     zz
64     abcabcabczz
65     >>abczz
66
67 /^(b+?|a){1,2}?c/
68     bc
69     bbc
70     bbbc
71     bac
72     bbac
73     aac
74     abbbbbbbbbbbc
75     bbbbbbbbbbbac
76     *** Failers
77     aaac
78     abbbbbbbbbbbac
79
80 /^(b+|a){1,2}c/
81     bc
82     bbc
83     bbbc
84     bac
85     bbac
86     aac
87     abbbbbbbbbbbc
88     bbbbbbbbbbbac
89     *** Failers
90     aaac
91     abbbbbbbbbbbac
92
93 /^(b+|a){1,2}?bc/
94     bbc
95
96 /^(b*|ba){1,2}?bc/
97     babc
98     bbabc
99     bababc
100     *** Failers
101     bababbc
102     babababc
103
104 /^(ba|b*){1,2}?bc/
105     babc
106     bbabc
107     bababc
108     *** Failers
109     bababbc
110     babababc
111
112 /^\ca\cA\c[\c{\c:/
113     \x01\x01\e;z
114
115 /^[ab\]cde]/
116     athing
117     bthing
118     ]thing
119     cthing
120     dthing
121     ething
122     *** Failers
123     fthing
124     [thing
125     \\thing
126
127 /^[]cde]/
128     ]thing
129     cthing
130     dthing
131     ething
132     *** Failers
133     athing
134     fthing
135
136 /^[^ab\]cde]/
137     fthing
138     [thing
139     \\thing
140     *** Failers
141     athing
142     bthing
143     ]thing
144     cthing
145     dthing
146     ething
147
148 /^[^]cde]/
149     athing
150     fthing
151     *** Failers
152     ]thing
153     cthing
154     dthing
155     ething
156
157 /^\\81/
158     \81
159
160 /^ÿ/
161     ÿ
162
163 /^[0-9]+$/
164     0
165     1
166     2
167     3
168     4
169     5
170     6
171     7
172     8
173     9
174     10
175     100
176     *** Failers
177     abc
178
179 /^.*nter/
180     enter
181     inter
182     uponter
183
184 /^xxx[0-9]+$/
185     xxx0
186     xxx1234
187     *** Failers
188     xxx
189
190 /^.+[0-9][0-9][0-9]$/
191     x123
192     xx123
193     123456
194     *** Failers
195     123
196     x1234
197
198 /^.+?[0-9][0-9][0-9]$/
199     x123
200     xx123
201     123456
202     *** Failers
203     123
204     x1234
205
206 /^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
207     abc!pqr=apquxz.ixr.zzz.ac.uk
208     *** Failers
209     !pqr=apquxz.ixr.zzz.ac.uk
210     abc!=apquxz.ixr.zzz.ac.uk
211     abc!pqr=apquxz:ixr.zzz.ac.uk
212     abc!pqr=apquxz.ixr.zzz.ac.ukk
213
214 /:/
215     Well, we need a colon: somewhere
216     *** Fail if we don't
217
218 /([\da-f:]+)$/i
219     0abc
220     abc
221     fed
222     E
223     ::
224     5f03:12C0::932e
225     fed def
226     Any old stuff
227     *** Failers
228     0zzz
229     gzzz
230     fed\x20
231     Any old rubbish
232
233 /^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
234     .1.2.3
235     A.12.123.0
236     *** Failers
237     .1.2.3333
238     1.2.3
239     1234.2.3
240
241 /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
242     1 IN SOA non-sp1 non-sp2(
243     1    IN    SOA    non-sp1    non-sp2   (
244     *** Failers
245     1IN SOA non-sp1 non-sp2(
246
247 /^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
248     a.
249     Z.
250     2.
251     ab-c.pq-r.
252     sxk.zzz.ac.uk.
253     x-.y-.
254     *** Failers
255     -abc.peq.
256
257 /^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
258     *.a
259     *.b0-a
260     *.c3-b.c
261     *.c-a.b-c
262     *** Failers
263     *.0
264     *.a-
265     *.a-b.c-
266     *.c-a.0-c
267
268 /^(?=ab(de))(abd)(e)/
269     abde
270
271 /^(?!(ab)de|x)(abd)(f)/
272     abdf
273
274 /^(?=(ab(cd)))(ab)/
275     abcd
276
277 /^[\da-f](\.[\da-f])*$/i
278     a.b.c.d
279     A.B.C.D
280     a.b.c.1.2.3.C
281
282 /^\".*\"\s*(;.*)?$/
283     \"1234\"
284     \"abcd\" ;
285     \"\" ; rhubarb
286     *** Failers
287     \"1234\" : things
288
289 /^$/
290     \
291     *** Failers
292
293 /   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/x
294     ab c
295     *** Failers
296     abc
297     ab cde
298
299 /(?x)   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/
300     ab c
301     *** Failers
302     abc
303     ab cde
304
305 /^   a\ b[c ]d       $/x
306     a bcd
307     a b d
308     *** Failers
309     abcd
310     ab d
311
312 /^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
313     abcdefhijklm
314
315 /^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
316     abcdefhijklm
317
318 /^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
319     a+ Z0+\x08\n\x1d\x12
320
321 /^[.^$|()*+?{,}]+/
322     .^\$(*+)|{?,?}
323
324 /^a*\w/
325     z
326     az
327     aaaz
328     a
329     aa
330     aaaa
331     a+
332     aa+
333
334 /^a*?\w/
335     z
336     az
337     aaaz
338     a
339     aa
340     aaaa
341     a+
342     aa+
343
344 /^a+\w/
345     az
346     aaaz
347     aa
348     aaaa
349     aa+
350
351 /^a+?\w/
352     az
353     aaaz
354     aa
355     aaaa
356     aa+
357
358 /^\d{8}\w{2,}/
359     1234567890
360     12345678ab
361     12345678__
362     *** Failers
363     1234567
364
365 /^[aeiou\d]{4,5}$/
366     uoie
367     1234
368     12345
369     aaaaa
370     *** Failers
371     123456
372
373 /^[aeiou\d]{4,5}?/
374     uoie
375     1234
376     12345
377     aaaaa
378     123456
379
380 /\A(abc|def)=(\1){2,3}\Z/
381     abc=abcabc
382     def=defdefdef
383     *** Failers
384     abc=defdef
385
386 /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
387     abcdefghijkcda2
388     abcdefghijkkkkcda2
389
390 /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
391     cataract cataract23
392     catatonic catatonic23
393     caterpillar caterpillar23
394
395
396 /^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]/
397     From abcd  Mon Sep 01 12:33:02 1997
398
399 /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
400     From abcd  Mon Sep 01 12:33:02 1997
401     From abcd  Mon Sep  1 12:33:02 1997
402     *** Failers
403     From abcd  Sep 01 12:33:02 1997
404
405 /^12.34/s
406     12\n34
407     12\r34
408
409 /\w+(?=\t)/
410     the quick brown\t fox
411
412 /foo(?!bar)(.*)/
413     foobar is foolish see?
414
415 /(?:(?!foo)...|^.{0,2})bar(.*)/
416     foobar crowbar etc
417     barrel
418     2barrel
419     A barrel
420
421 /^(\D*)(?=\d)(?!123)/
422     abc456
423     *** Failers
424     abc123
425
426 /^1234(?# test newlines
427   inside)/
428     1234
429
430 /^1234 #comment in extended re
431   /x
432     1234
433
434 /#rhubarb
435   abcd/x
436     abcd
437
438 /^abcd#rhubarb/x
439     abcd
440
441 /^(a)\1{2,3}(.)/
442     aaab
443     aaaab
444     aaaaab
445     aaaaaab
446
447 /(?!^)abc/
448     the abc
449     *** Failers
450     abc
451
452 /(?=^)abc/
453     abc
454     *** Failers
455     the abc
456
457 /^[ab]{1,3}(ab*|b)/
458     aabbbbb
459
460 /^[ab]{1,3}?(ab*|b)/
461     aabbbbb
462
463 /^[ab]{1,3}?(ab*?|b)/
464     aabbbbb
465
466 /^[ab]{1,3}(ab*?|b)/
467     aabbbbb
468
469 /  (?: [\040\t] |  \(
470 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
471 \)  )*                          # optional leading comment
472 (?:    (?:
473 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
474 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
475 |
476 " (?:                      # opening quote...
477 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
478 |                     #    or
479 \\ [^\x80-\xff]           #   Escaped something (something != CR)
480 )* "  # closing quote
481 )                    # initial word
482 (?:  (?: [\040\t] |  \(
483 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
484 \)  )*  \.  (?: [\040\t] |  \(
485 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
486 \)  )*   (?:
487 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
488 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
489 |
490 " (?:                      # opening quote...
491 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
492 |                     #    or
493 \\ [^\x80-\xff]           #   Escaped something (something != CR)
494 )* "  # closing quote
495 )  )* # further okay, if led by a period
496 (?: [\040\t] |  \(
497 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
498 \)  )*  @  (?: [\040\t] |  \(
499 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
500 \)  )*    (?:
501 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
502 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
503 |   \[                         # [
504 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
505 \]                        #           ]
506 )                           # initial subdomain
507 (?:                                  #
508 (?: [\040\t] |  \(
509 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
510 \)  )*  \.                        # if led by a period...
511 (?: [\040\t] |  \(
512 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
513 \)  )*   (?:
514 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
515 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
516 |   \[                         # [
517 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
518 \]                        #           ]
519 )                     #   ...further okay
520 )*
521 # address
522 |                     #  or
523 (?:
524 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
525 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
526 |
527 " (?:                      # opening quote...
528 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
529 |                     #    or
530 \\ [^\x80-\xff]           #   Escaped something (something != CR)
531 )* "  # closing quote
532 )             # one word, optionally followed by....
533 (?:
534 [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
535 \(
536 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
537 \)       |  # comments, or...
538
539 " (?:                      # opening quote...
540 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
541 |                     #    or
542 \\ [^\x80-\xff]           #   Escaped something (something != CR)
543 )* "  # closing quote
544 # quoted strings
545 )*
546 <  (?: [\040\t] |  \(
547 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
548 \)  )*                     # leading <
549 (?:  @  (?: [\040\t] |  \(
550 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
551 \)  )*    (?:
552 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
553 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
554 |   \[                         # [
555 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
556 \]                        #           ]
557 )                           # initial subdomain
558 (?:                                  #
559 (?: [\040\t] |  \(
560 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
561 \)  )*  \.                        # if led by a period...
562 (?: [\040\t] |  \(
563 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
564 \)  )*   (?:
565 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
566 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
567 |   \[                         # [
568 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
569 \]                        #           ]
570 )                     #   ...further okay
571 )*
572
573 (?:  (?: [\040\t] |  \(
574 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
575 \)  )*  ,  (?: [\040\t] |  \(
576 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
577 \)  )*  @  (?: [\040\t] |  \(
578 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
579 \)  )*    (?:
580 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
581 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
582 |   \[                         # [
583 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
584 \]                        #           ]
585 )                           # initial subdomain
586 (?:                                  #
587 (?: [\040\t] |  \(
588 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
589 \)  )*  \.                        # if led by a period...
590 (?: [\040\t] |  \(
591 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
592 \)  )*   (?:
593 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
594 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
595 |   \[                         # [
596 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
597 \]                        #           ]
598 )                     #   ...further okay
599 )*
600 )* # further okay, if led by comma
601 :                                # closing colon
602 (?: [\040\t] |  \(
603 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
604 \)  )*  )? #       optional route
605 (?:
606 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
607 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
608 |
609 " (?:                      # opening quote...
610 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
611 |                     #    or
612 \\ [^\x80-\xff]           #   Escaped something (something != CR)
613 )* "  # closing quote
614 )                    # initial word
615 (?:  (?: [\040\t] |  \(
616 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
617 \)  )*  \.  (?: [\040\t] |  \(
618 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
619 \)  )*   (?:
620 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
621 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
622 |
623 " (?:                      # opening quote...
624 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
625 |                     #    or
626 \\ [^\x80-\xff]           #   Escaped something (something != CR)
627 )* "  # closing quote
628 )  )* # further okay, if led by a period
629 (?: [\040\t] |  \(
630 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
631 \)  )*  @  (?: [\040\t] |  \(
632 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
633 \)  )*    (?:
634 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
635 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
636 |   \[                         # [
637 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
638 \]                        #           ]
639 )                           # initial subdomain
640 (?:                                  #
641 (?: [\040\t] |  \(
642 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
643 \)  )*  \.                        # if led by a period...
644 (?: [\040\t] |  \(
645 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
646 \)  )*   (?:
647 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
648 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
649 |   \[                         # [
650 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
651 \]                        #           ]
652 )                     #   ...further okay
653 )*
654 #       address spec
655 (?: [\040\t] |  \(
656 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
657 \)  )*  > #                  trailing >
658 # name and address
659 )  (?: [\040\t] |  \(
660 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
661 \)  )*                       # optional trailing comment
662 /x
663     Alan Other <user\@dom.ain>
664     <user\@dom.ain>
665     user\@dom.ain
666     \"A. Other\" <user.1234\@dom.ain> (a comment)
667     A. Other <user.1234\@dom.ain> (a comment)
668     \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
669     A missing angle <user\@some.where
670     *** Failers
671     The quick brown fox
672
673 /[\040\t]*                    # Nab whitespace.
674 (?:
675 \(                              #  (
676 [^\\\x80-\xff\n\015()] *                             #     normal*
677 (?:                                 #       (
678 (?:  \\ [^\x80-\xff]  |
679 \(                            #  (
680 [^\\\x80-\xff\n\015()] *                            #     normal*
681 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
682 \)                           #                       )
683 )    #         special
684 [^\\\x80-\xff\n\015()] *                         #         normal*
685 )*                                  #            )*
686 \)                             #                )
687 [\040\t]* )*    # If comment found, allow more spaces.
688 # optional leading comment
689 (?:
690 (?:
691 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
692 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
693 # Atom
694 |                       #  or
695 "                                     # "
696 [^\\\x80-\xff\n\015"] *                            #   normal
697 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
698 "                                     #        "
699 # Quoted string
700 )
701 [\040\t]*                    # Nab whitespace.
702 (?:
703 \(                              #  (
704 [^\\\x80-\xff\n\015()] *                             #     normal*
705 (?:                                 #       (
706 (?:  \\ [^\x80-\xff]  |
707 \(                            #  (
708 [^\\\x80-\xff\n\015()] *                            #     normal*
709 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
710 \)                           #                       )
711 )    #         special
712 [^\\\x80-\xff\n\015()] *                         #         normal*
713 )*                                  #            )*
714 \)                             #                )
715 [\040\t]* )*    # If comment found, allow more spaces.
716 (?:
717 \.
718 [\040\t]*                    # Nab whitespace.
719 (?:
720 \(                              #  (
721 [^\\\x80-\xff\n\015()] *                             #     normal*
722 (?:                                 #       (
723 (?:  \\ [^\x80-\xff]  |
724 \(                            #  (
725 [^\\\x80-\xff\n\015()] *                            #     normal*
726 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
727 \)                           #                       )
728 )    #         special
729 [^\\\x80-\xff\n\015()] *                         #         normal*
730 )*                                  #            )*
731 \)                             #                )
732 [\040\t]* )*    # If comment found, allow more spaces.
733 (?:
734 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
735 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
736 # Atom
737 |                       #  or
738 "                                     # "
739 [^\\\x80-\xff\n\015"] *                            #   normal
740 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
741 "                                     #        "
742 # Quoted string
743 )
744 [\040\t]*                    # Nab whitespace.
745 (?:
746 \(                              #  (
747 [^\\\x80-\xff\n\015()] *                             #     normal*
748 (?:                                 #       (
749 (?:  \\ [^\x80-\xff]  |
750 \(                            #  (
751 [^\\\x80-\xff\n\015()] *                            #     normal*
752 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
753 \)                           #                       )
754 )    #         special
755 [^\\\x80-\xff\n\015()] *                         #         normal*
756 )*                                  #            )*
757 \)                             #                )
758 [\040\t]* )*    # If comment found, allow more spaces.
759 # additional words
760 )*
761 @
762 [\040\t]*                    # Nab whitespace.
763 (?:
764 \(                              #  (
765 [^\\\x80-\xff\n\015()] *                             #     normal*
766 (?:                                 #       (
767 (?:  \\ [^\x80-\xff]  |
768 \(                            #  (
769 [^\\\x80-\xff\n\015()] *                            #     normal*
770 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
771 \)                           #                       )
772 )    #         special
773 [^\\\x80-\xff\n\015()] *                         #         normal*
774 )*                                  #            )*
775 \)                             #                )
776 [\040\t]* )*    # If comment found, allow more spaces.
777 (?:
778 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
779 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
780 |
781 \[                            # [
782 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
783 \]                           #           ]
784 )
785 [\040\t]*                    # Nab whitespace.
786 (?:
787 \(                              #  (
788 [^\\\x80-\xff\n\015()] *                             #     normal*
789 (?:                                 #       (
790 (?:  \\ [^\x80-\xff]  |
791 \(                            #  (
792 [^\\\x80-\xff\n\015()] *                            #     normal*
793 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
794 \)                           #                       )
795 )    #         special
796 [^\\\x80-\xff\n\015()] *                         #         normal*
797 )*                                  #            )*
798 \)                             #                )
799 [\040\t]* )*    # If comment found, allow more spaces.
800 # optional trailing comments
801 (?:
802 \.
803 [\040\t]*                    # Nab whitespace.
804 (?:
805 \(                              #  (
806 [^\\\x80-\xff\n\015()] *                             #     normal*
807 (?:                                 #       (
808 (?:  \\ [^\x80-\xff]  |
809 \(                            #  (
810 [^\\\x80-\xff\n\015()] *                            #     normal*
811 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
812 \)                           #                       )
813 )    #         special
814 [^\\\x80-\xff\n\015()] *                         #         normal*
815 )*                                  #            )*
816 \)                             #                )
817 [\040\t]* )*    # If comment found, allow more spaces.
818 (?:
819 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
820 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
821 |
822 \[                            # [
823 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
824 \]                           #           ]
825 )
826 [\040\t]*                    # Nab whitespace.
827 (?:
828 \(                              #  (
829 [^\\\x80-\xff\n\015()] *                             #     normal*
830 (?:                                 #       (
831 (?:  \\ [^\x80-\xff]  |
832 \(                            #  (
833 [^\\\x80-\xff\n\015()] *                            #     normal*
834 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
835 \)                           #                       )
836 )    #         special
837 [^\\\x80-\xff\n\015()] *                         #         normal*
838 )*                                  #            )*
839 \)                             #                )
840 [\040\t]* )*    # If comment found, allow more spaces.
841 # optional trailing comments
842 )*
843 # address
844 |                             #  or
845 (?:
846 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
847 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
848 # Atom
849 |                       #  or
850 "                                     # "
851 [^\\\x80-\xff\n\015"] *                            #   normal
852 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
853 "                                     #        "
854 # Quoted string
855 )
856 # leading word
857 [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *               # "normal" atoms and or spaces
858 (?:
859 (?:
860 \(                              #  (
861 [^\\\x80-\xff\n\015()] *                             #     normal*
862 (?:                                 #       (
863 (?:  \\ [^\x80-\xff]  |
864 \(                            #  (
865 [^\\\x80-\xff\n\015()] *                            #     normal*
866 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
867 \)                           #                       )
868 )    #         special
869 [^\\\x80-\xff\n\015()] *                         #         normal*
870 )*                                  #            )*
871 \)                             #                )
872 |
873 "                                     # "
874 [^\\\x80-\xff\n\015"] *                            #   normal
875 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
876 "                                     #        "
877 ) # "special" comment or quoted string
878 [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *            #  more "normal"
879 )*
880 <
881 [\040\t]*                    # Nab whitespace.
882 (?:
883 \(                              #  (
884 [^\\\x80-\xff\n\015()] *                             #     normal*
885 (?:                                 #       (
886 (?:  \\ [^\x80-\xff]  |
887 \(                            #  (
888 [^\\\x80-\xff\n\015()] *                            #     normal*
889 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
890 \)                           #                       )
891 )    #         special
892 [^\\\x80-\xff\n\015()] *                         #         normal*
893 )*                                  #            )*
894 \)                             #                )
895 [\040\t]* )*    # If comment found, allow more spaces.
896 # <
897 (?:
898 @
899 [\040\t]*                    # Nab whitespace.
900 (?:
901 \(                              #  (
902 [^\\\x80-\xff\n\015()] *                             #     normal*
903 (?:                                 #       (
904 (?:  \\ [^\x80-\xff]  |
905 \(                            #  (
906 [^\\\x80-\xff\n\015()] *                            #     normal*
907 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
908 \)                           #                       )
909 )    #         special
910 [^\\\x80-\xff\n\015()] *                         #         normal*
911 )*                                  #            )*
912 \)                             #                )
913 [\040\t]* )*    # If comment found, allow more spaces.
914 (?:
915 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
916 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
917 |
918 \[                            # [
919 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
920 \]                           #           ]
921 )
922 [\040\t]*                    # Nab whitespace.
923 (?:
924 \(                              #  (
925 [^\\\x80-\xff\n\015()] *                             #     normal*
926 (?:                                 #       (
927 (?:  \\ [^\x80-\xff]  |
928 \(                            #  (
929 [^\\\x80-\xff\n\015()] *                            #     normal*
930 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
931 \)                           #                       )
932 )    #         special
933 [^\\\x80-\xff\n\015()] *                         #         normal*
934 )*                                  #            )*
935 \)                             #                )
936 [\040\t]* )*    # If comment found, allow more spaces.
937 # optional trailing comments
938 (?:
939 \.
940 [\040\t]*                    # Nab whitespace.
941 (?:
942 \(                              #  (
943 [^\\\x80-\xff\n\015()] *                             #     normal*
944 (?:                                 #       (
945 (?:  \\ [^\x80-\xff]  |
946 \(                            #  (
947 [^\\\x80-\xff\n\015()] *                            #     normal*
948 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
949 \)                           #                       )
950 )    #         special
951 [^\\\x80-\xff\n\015()] *                         #         normal*
952 )*                                  #            )*
953 \)                             #                )
954 [\040\t]* )*    # If comment found, allow more spaces.
955 (?:
956 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
957 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
958 |
959 \[                            # [
960 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
961 \]                           #           ]
962 )
963 [\040\t]*                    # Nab whitespace.
964 (?:
965 \(                              #  (
966 [^\\\x80-\xff\n\015()] *                             #     normal*
967 (?:                                 #       (
968 (?:  \\ [^\x80-\xff]  |
969 \(                            #  (
970 [^\\\x80-\xff\n\015()] *                            #     normal*
971 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
972 \)                           #                       )
973 )    #         special
974 [^\\\x80-\xff\n\015()] *                         #         normal*
975 )*                                  #            )*
976 \)                             #                )
977 [\040\t]* )*    # If comment found, allow more spaces.
978 # optional trailing comments
979 )*
980 (?: ,
981 [\040\t]*                    # Nab whitespace.
982 (?:
983 \(                              #  (
984 [^\\\x80-\xff\n\015()] *                             #     normal*
985 (?:                                 #       (
986 (?:  \\ [^\x80-\xff]  |
987 \(                            #  (
988 [^\\\x80-\xff\n\015()] *                            #     normal*
989 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
990 \)                           #                       )
991 )    #         special
992 [^\\\x80-\xff\n\015()] *                         #         normal*
993 )*                                  #            )*
994 \)                             #                )
995 [\040\t]* )*    # If comment found, allow more spaces.
996 @
997 [\040\t]*                    # Nab whitespace.
998 (?:
999 \(                              #  (
1000 [^\\\x80-\xff\n\015()] *                             #     normal*
1001 (?:                                 #       (
1002 (?:  \\ [^\x80-\xff]  |
1003 \(                            #  (
1004 [^\\\x80-\xff\n\015()] *                            #     normal*
1005 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1006 \)                           #                       )
1007 )    #         special
1008 [^\\\x80-\xff\n\015()] *                         #         normal*
1009 )*                                  #            )*
1010 \)                             #                )
1011 [\040\t]* )*    # If comment found, allow more spaces.
1012 (?:
1013 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1014 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1015 |
1016 \[                            # [
1017 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1018 \]                           #           ]
1019 )
1020 [\040\t]*                    # Nab whitespace.
1021 (?:
1022 \(                              #  (
1023 [^\\\x80-\xff\n\015()] *                             #     normal*
1024 (?:                                 #       (
1025 (?:  \\ [^\x80-\xff]  |
1026 \(                            #  (
1027 [^\\\x80-\xff\n\015()] *                            #     normal*
1028 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1029 \)                           #                       )
1030 )    #         special
1031 [^\\\x80-\xff\n\015()] *                         #         normal*
1032 )*                                  #            )*
1033 \)                             #                )
1034 [\040\t]* )*    # If comment found, allow more spaces.
1035 # optional trailing comments
1036 (?:
1037 \.
1038 [\040\t]*                    # Nab whitespace.
1039 (?:
1040 \(                              #  (
1041 [^\\\x80-\xff\n\015()] *                             #     normal*
1042 (?:                                 #       (
1043 (?:  \\ [^\x80-\xff]  |
1044 \(                            #  (
1045 [^\\\x80-\xff\n\015()] *                            #     normal*
1046 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1047 \)                           #                       )
1048 )    #         special
1049 [^\\\x80-\xff\n\015()] *                         #         normal*
1050 )*                                  #            )*
1051 \)                             #                )
1052 [\040\t]* )*    # If comment found, allow more spaces.
1053 (?:
1054 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1055 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1056 |
1057 \[                            # [
1058 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1059 \]                           #           ]
1060 )
1061 [\040\t]*                    # Nab whitespace.
1062 (?:
1063 \(                              #  (
1064 [^\\\x80-\xff\n\015()] *                             #     normal*
1065 (?:                                 #       (
1066 (?:  \\ [^\x80-\xff]  |
1067 \(                            #  (
1068 [^\\\x80-\xff\n\015()] *                            #     normal*
1069 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1070 \)                           #                       )
1071 )    #         special
1072 [^\\\x80-\xff\n\015()] *                         #         normal*
1073 )*                                  #            )*
1074 \)                             #                )
1075 [\040\t]* )*    # If comment found, allow more spaces.
1076 # optional trailing comments
1077 )*
1078 )*  # additional domains
1079 :
1080 [\040\t]*                    # Nab whitespace.
1081 (?:
1082 \(                              #  (
1083 [^\\\x80-\xff\n\015()] *                             #     normal*
1084 (?:                                 #       (
1085 (?:  \\ [^\x80-\xff]  |
1086 \(                            #  (
1087 [^\\\x80-\xff\n\015()] *                            #     normal*
1088 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1089 \)                           #                       )
1090 )    #         special
1091 [^\\\x80-\xff\n\015()] *                         #         normal*
1092 )*                                  #            )*
1093 \)                             #                )
1094 [\040\t]* )*    # If comment found, allow more spaces.
1095 # optional trailing comments
1096 )?     #       optional route
1097 (?:
1098 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1099 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1100 # Atom
1101 |                       #  or
1102 "                                     # "
1103 [^\\\x80-\xff\n\015"] *                            #   normal
1104 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1105 "                                     #        "
1106 # Quoted string
1107 )
1108 [\040\t]*                    # Nab whitespace.
1109 (?:
1110 \(                              #  (
1111 [^\\\x80-\xff\n\015()] *                             #     normal*
1112 (?:                                 #       (
1113 (?:  \\ [^\x80-\xff]  |
1114 \(                            #  (
1115 [^\\\x80-\xff\n\015()] *                            #     normal*
1116 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1117 \)                           #                       )
1118 )    #         special
1119 [^\\\x80-\xff\n\015()] *                         #         normal*
1120 )*                                  #            )*
1121 \)                             #                )
1122 [\040\t]* )*    # If comment found, allow more spaces.
1123 (?:
1124 \.
1125 [\040\t]*                    # Nab whitespace.
1126 (?:
1127 \(                              #  (
1128 [^\\\x80-\xff\n\015()] *                             #     normal*
1129 (?:                                 #       (
1130 (?:  \\ [^\x80-\xff]  |
1131 \(                            #  (
1132 [^\\\x80-\xff\n\015()] *                            #     normal*
1133 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1134 \)                           #                       )
1135 )    #         special
1136 [^\\\x80-\xff\n\015()] *                         #         normal*
1137 )*                                  #            )*
1138 \)                             #                )
1139 [\040\t]* )*    # If comment found, allow more spaces.
1140 (?:
1141 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1142 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1143 # Atom
1144 |                       #  or
1145 "                                     # "
1146 [^\\\x80-\xff\n\015"] *                            #   normal
1147 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1148 "                                     #        "
1149 # Quoted string
1150 )
1151 [\040\t]*                    # Nab whitespace.
1152 (?:
1153 \(                              #  (
1154 [^\\\x80-\xff\n\015()] *                             #     normal*
1155 (?:                                 #       (
1156 (?:  \\ [^\x80-\xff]  |
1157 \(                            #  (
1158 [^\\\x80-\xff\n\015()] *                            #     normal*
1159 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1160 \)                           #                       )
1161 )    #         special
1162 [^\\\x80-\xff\n\015()] *                         #         normal*
1163 )*                                  #            )*
1164 \)                             #                )
1165 [\040\t]* )*    # If comment found, allow more spaces.
1166 # additional words
1167 )*
1168 @
1169 [\040\t]*                    # Nab whitespace.
1170 (?:
1171 \(                              #  (
1172 [^\\\x80-\xff\n\015()] *                             #     normal*
1173 (?:                                 #       (
1174 (?:  \\ [^\x80-\xff]  |
1175 \(                            #  (
1176 [^\\\x80-\xff\n\015()] *                            #     normal*
1177 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1178 \)                           #                       )
1179 )    #         special
1180 [^\\\x80-\xff\n\015()] *                         #         normal*
1181 )*                                  #            )*
1182 \)                             #                )
1183 [\040\t]* )*    # If comment found, allow more spaces.
1184 (?:
1185 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1186 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1187 |
1188 \[                            # [
1189 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1190 \]                           #           ]
1191 )
1192 [\040\t]*                    # Nab whitespace.
1193 (?:
1194 \(                              #  (
1195 [^\\\x80-\xff\n\015()] *                             #     normal*
1196 (?:                                 #       (
1197 (?:  \\ [^\x80-\xff]  |
1198 \(                            #  (
1199 [^\\\x80-\xff\n\015()] *                            #     normal*
1200 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1201 \)                           #                       )
1202 )    #         special
1203 [^\\\x80-\xff\n\015()] *                         #         normal*
1204 )*                                  #            )*
1205 \)                             #                )
1206 [\040\t]* )*    # If comment found, allow more spaces.
1207 # optional trailing comments
1208 (?:
1209 \.
1210 [\040\t]*                    # Nab whitespace.
1211 (?:
1212 \(                              #  (
1213 [^\\\x80-\xff\n\015()] *                             #     normal*
1214 (?:                                 #       (
1215 (?:  \\ [^\x80-\xff]  |
1216 \(                            #  (
1217 [^\\\x80-\xff\n\015()] *                            #     normal*
1218 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1219 \)                           #                       )
1220 )    #         special
1221 [^\\\x80-\xff\n\015()] *                         #         normal*
1222 )*                                  #            )*
1223 \)                             #                )
1224 [\040\t]* )*    # If comment found, allow more spaces.
1225 (?:
1226 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1227 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1228 |
1229 \[                            # [
1230 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1231 \]                           #           ]
1232 )
1233 [\040\t]*                    # Nab whitespace.
1234 (?:
1235 \(                              #  (
1236 [^\\\x80-\xff\n\015()] *                             #     normal*
1237 (?:                                 #       (
1238 (?:  \\ [^\x80-\xff]  |
1239 \(                            #  (
1240 [^\\\x80-\xff\n\015()] *                            #     normal*
1241 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1242 \)                           #                       )
1243 )    #         special
1244 [^\\\x80-\xff\n\015()] *                         #         normal*
1245 )*                                  #            )*
1246 \)                             #                )
1247 [\040\t]* )*    # If comment found, allow more spaces.
1248 # optional trailing comments
1249 )*
1250 #       address spec
1251 >                    #                 >
1252 # name and address
1253 )
1254 /x
1255     Alan Other <user\@dom.ain>
1256     <user\@dom.ain>
1257     user\@dom.ain
1258     \"A. Other\" <user.1234\@dom.ain> (a comment)
1259     A. Other <user.1234\@dom.ain> (a comment)
1260     \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
1261     A missing angle <user\@some.where
1262     *** Failers
1263     The quick brown fox
1264
1265 /abc\0def\00pqr\000xyz\0000AB/
1266     abc\0def\00pqr\000xyz\0000AB
1267     abc456 abc\0def\00pqr\000xyz\0000ABCDE
1268
1269 /abc\x0def\x00pqr\x000xyz\x0000AB/
1270     abc\x0def\x00pqr\x000xyz\x0000AB
1271     abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
1272
1273 /^[\000-\037]/
1274     \0A
1275     \01B
1276     \037C
1277
1278 /\0*/
1279     \0\0\0\0
1280
1281 /A\x0{2,3}Z/
1282     The A\x0\x0Z
1283     An A\0\x0\0Z
1284     *** Failers
1285     A\0Z
1286     A\0\x0\0\x0Z
1287
1288 /^(cow|)\1(bell)/
1289     cowcowbell
1290     bell
1291     *** Failers
1292     cowbell
1293
1294 /^\s/
1295     \040abc
1296     \x0cabc
1297     \nabc
1298     \rabc
1299     \tabc
1300     *** Failers
1301     abc
1302
1303 /^a     b
1304     \f  c/x
1305     abc
1306
1307 /^(a|)\1*b/
1308     ab
1309     aaaab
1310     b
1311     *** Failers
1312     acb
1313
1314 /^(a|)\1+b/
1315     aab
1316     aaaab
1317     b
1318     *** Failers
1319     ab
1320
1321 /^(a|)\1?b/
1322     ab
1323     aab
1324     b
1325     *** Failers
1326     acb
1327
1328 /^(a|)\1{2}b/
1329     aaab
1330     b
1331     *** Failers
1332     ab
1333     aab
1334     aaaab
1335
1336 /^(a|)\1{2,3}b/
1337     aaab
1338     aaaab
1339     b
1340     *** Failers
1341     ab
1342     aab
1343     aaaaab
1344
1345 /ab{1,3}bc/
1346     abbbbc
1347     abbbc
1348     abbc
1349     *** Failers
1350     abc
1351     abbbbbc
1352
1353 /([^.]*)\.([^:]*):[T ]+(.*)/
1354     track1.title:TBlah blah blah
1355
1356 /([^.]*)\.([^:]*):[T ]+(.*)/i
1357     track1.title:TBlah blah blah
1358
1359 /([^.]*)\.([^:]*):[t ]+(.*)/i
1360     track1.title:TBlah blah blah
1361
1362 /^[W-c]+$/
1363     WXY_^abc
1364     *** Failers
1365     wxy
1366
1367 /^[W-c]+$/i
1368     WXY_^abc
1369     wxy_^ABC
1370
1371 /^[\x3f-\x5F]+$/i
1372     WXY_^abc
1373     wxy_^ABC
1374
1375 /^abc$/m
1376     abc
1377     qqq\nabc
1378     abc\nzzz
1379     qqq\nabc\nzzz
1380
1381 /^abc$/
1382     abc
1383     *** Failers
1384     qqq\nabc
1385     abc\nzzz
1386     qqq\nabc\nzzz
1387
1388 /\Aabc\Z/m
1389     abc
1390     abc\n 
1391     *** Failers
1392     qqq\nabc
1393     abc\nzzz
1394     qqq\nabc\nzzz
1395     
1396 /\A(.)*\Z/s
1397     abc\ndef
1398
1399 /\A(.)*\Z/m
1400     *** Failers
1401     abc\ndef
1402
1403 /(?:b)|(?::+)/
1404     b::c
1405     c::b
1406
1407 /[-az]+/
1408     az-
1409     *** Failers
1410     b
1411
1412 /[az-]+/
1413     za-
1414     *** Failers
1415     b
1416
1417 /[a\-z]+/
1418     a-z
1419     *** Failers
1420     b
1421
1422 /[a-z]+/
1423     abcdxyz
1424
1425 /[\d-]+/
1426     12-34
1427     *** Failers
1428     aaa
1429
1430 /[\d-z]+/
1431     12-34z
1432     *** Failers
1433     aaa
1434
1435 /\x5c/
1436     \\
1437
1438 /\x20Z/
1439     the Zoo
1440     *** Failers
1441     Zulu
1442
1443 /(abc)\1/i
1444     abcabc
1445     ABCabc
1446     abcABC
1447
1448 /ab{3cd/
1449     ab{3cd
1450
1451 /ab{3,cd/
1452     ab{3,cd
1453
1454 /ab{3,4a}cd/
1455     ab{3,4a}cd
1456
1457 /{4,5a}bc/
1458     {4,5a}bc
1459
1460 /abc$/
1461     abc
1462     abc\n
1463     *** Failers
1464     abc\ndef
1465
1466 /(abc)\123/
1467     abc\x53
1468
1469 /(abc)\223/
1470     abc\x93
1471
1472 /(abc)\323/
1473     abc\xd3
1474
1475 /(abc)\100/
1476     abc\x40
1477     abc\100
1478
1479 /(abc)\1000/
1480     abc\x400
1481     abc\x40\x30
1482     abc\1000
1483     abc\100\x30
1484     abc\100\060
1485     abc\100\60
1486
1487 /abc\81/
1488     abc\081
1489     abc\0\x38\x31
1490
1491 /abc\91/
1492     abc\091
1493     abc\0\x39\x31
1494
1495 /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
1496     abcdefghijkllS
1497
1498 /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
1499     abcdefghijk\12S
1500
1501 /ab\idef/
1502     abidef
1503
1504 /a{0}bc/
1505     bc
1506
1507 /(a|(bc)){0,0}?xyz/
1508     xyz
1509
1510 /abc[\10]de/
1511     abc\010de
1512
1513 /abc[\1]de/
1514     abc\1de
1515
1516 /(abc)[\1]de/
1517     abc\1de
1518
1519 /(?s)a.b/
1520     a\nb
1521
1522 /^([^a])([^\b])([^c]*)([^d]{3,4})/
1523     baNOTccccd
1524     baNOTcccd
1525     baNOTccd
1526     bacccd
1527     *** Failers
1528     anything
1529     b\bc   
1530     baccd
1531
1532 /[^a]/
1533     Abc
1534   
1535 /[^a]/i
1536     Abc 
1537
1538 /[^a]+/
1539     AAAaAbc
1540   
1541 /[^a]+/i
1542     AAAaAbc 
1543
1544 /[^a]+/
1545     bbb\nccc
1546    
1547 /[^k]$/
1548     abc
1549     *** Failers
1550     abk   
1551    
1552 /[^k]{2,3}$/
1553     abc
1554     kbc
1555     kabc 
1556     *** Failers
1557     abk
1558     akb
1559     akk 
1560
1561 /^\d{8,}\@.+[^k]$/
1562     12345678\@a.b.c.d
1563     123456789\@x.y.z
1564     *** Failers
1565     12345678\@x.y.uk
1566     1234567\@a.b.c.d       
1567
1568 /(a)\1{8,}/
1569     aaaaaaaaa
1570     aaaaaaaaaa
1571     *** Failers
1572     aaaaaaa   
1573
1574 /[^a]/
1575     aaaabcd
1576     aaAabcd 
1577
1578 /[^a]/i
1579     aaaabcd
1580     aaAabcd 
1581
1582 /[^az]/
1583     aaaabcd
1584     aaAabcd 
1585
1586 /[^az]/i
1587     aaaabcd
1588     aaAabcd 
1589
1590 /\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/
1591  \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
1592
1593 /P[^*]TAIRE[^*]{1,6}?LL/
1594     xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
1595
1596 /P[^*]TAIRE[^*]{1,}?LL/
1597     xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
1598
1599 /(\.\d\d[1-9]?)\d+/
1600     1.230003938
1601     1.875000282   
1602     1.235  
1603                   
1604 /(\.\d\d((?=0)|\d(?=\d)))/
1605     1.230003938      
1606     1.875000282
1607     *** Failers 
1608     1.235 
1609     
1610 /a(?)b/
1611     ab 
1612  
1613 /\b(foo)\s+(\w+)/i
1614     Food is on the foo table
1615     
1616 /foo(.*)bar/
1617     The food is under the bar in the barn.
1618     
1619 /foo(.*?)bar/  
1620     The food is under the bar in the barn.
1621
1622 /(.*)(\d*)/
1623     I have 2 numbers: 53147
1624     
1625 /(.*)(\d+)/
1626     I have 2 numbers: 53147
1627  
1628 /(.*?)(\d*)/
1629     I have 2 numbers: 53147
1630
1631 /(.*?)(\d+)/
1632     I have 2 numbers: 53147
1633
1634 /(.*)(\d+)$/
1635     I have 2 numbers: 53147
1636
1637 /(.*?)(\d+)$/
1638     I have 2 numbers: 53147
1639
1640 /(.*)\b(\d+)$/
1641     I have 2 numbers: 53147
1642
1643 /(.*\D)(\d+)$/
1644     I have 2 numbers: 53147
1645
1646 /^\D*(?!123)/
1647     ABC123
1648      
1649 /^(\D*)(?=\d)(?!123)/
1650     ABC445
1651     *** Failers
1652     ABC123
1653     
1654 /^[W-]46]/
1655     W46]789 
1656     -46]789
1657     *** Failers
1658     Wall
1659     Zebra
1660     42
1661     [abcd] 
1662     ]abcd[
1663        
1664 /^[W-\]46]/
1665     W46]789 
1666     Wall
1667     Zebra
1668     Xylophone  
1669     42
1670     [abcd] 
1671     ]abcd[
1672     \\backslash 
1673     *** Failers
1674     -46]789
1675     well
1676     
1677 /\d\d\/\d\d\/\d\d\d\d/
1678     01/01/2000
1679
1680 /word (?:[a-zA-Z0-9]+ ){0,10}otherword/
1681   word cat dog elephant mussel cow horse canary baboon snake shark otherword
1682   word cat dog elephant mussel cow horse canary baboon snake shark
1683
1684 /word (?:[a-zA-Z0-9]+ ){0,300}otherword/
1685   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
1686
1687 /^(a){0,0}/
1688     bcd
1689     abc
1690     aab     
1691
1692 /^(a){0,1}/
1693     bcd
1694     abc
1695     aab  
1696
1697 /^(a){0,2}/
1698     bcd
1699     abc
1700     aab  
1701
1702 /^(a){0,3}/
1703     bcd
1704     abc
1705     aab
1706     aaa   
1707
1708 /^(a){0,}/
1709     bcd
1710     abc
1711     aab
1712     aaa
1713     aaaaaaaa    
1714
1715 /^(a){1,1}/
1716     bcd
1717     abc
1718     aab  
1719
1720 /^(a){1,2}/
1721     bcd
1722     abc
1723     aab  
1724
1725 /^(a){1,3}/
1726     bcd
1727     abc
1728     aab
1729     aaa   
1730
1731 /^(a){1,}/
1732     bcd
1733     abc
1734     aab
1735     aaa
1736     aaaaaaaa    
1737
1738 /.*\.gif/
1739     borfle\nbib.gif\nno
1740
1741 /.{0,}\.gif/
1742     borfle\nbib.gif\nno
1743
1744 /.*\.gif/m
1745     borfle\nbib.gif\nno
1746
1747 /.*\.gif/s
1748     borfle\nbib.gif\nno
1749
1750 /.*\.gif/ms
1751     borfle\nbib.gif\nno
1752     
1753 /.*$/
1754     borfle\nbib.gif\nno
1755
1756 /.*$/m
1757     borfle\nbib.gif\nno
1758
1759 /.*$/s
1760     borfle\nbib.gif\nno
1761
1762 /.*$/ms
1763     borfle\nbib.gif\nno
1764     
1765 /.*$/
1766     borfle\nbib.gif\nno\n
1767
1768 /.*$/m
1769     borfle\nbib.gif\nno\n
1770
1771 /.*$/s
1772     borfle\nbib.gif\nno\n
1773
1774 /.*$/ms
1775     borfle\nbib.gif\nno\n
1776     
1777 /(.*X|^B)/
1778     abcde\n1234Xyz
1779     BarFoo 
1780     *** Failers
1781     abcde\nBar  
1782
1783 /(.*X|^B)/m
1784     abcde\n1234Xyz
1785     BarFoo 
1786     abcde\nBar  
1787
1788 /(.*X|^B)/s
1789     abcde\n1234Xyz
1790     BarFoo 
1791     *** Failers
1792     abcde\nBar  
1793
1794 /(.*X|^B)/ms
1795     abcde\n1234Xyz
1796     BarFoo 
1797     abcde\nBar  
1798
1799 /(?s)(.*X|^B)/
1800     abcde\n1234Xyz
1801     BarFoo 
1802     *** Failers 
1803     abcde\nBar  
1804
1805 /(?s:.*X|^B)/
1806     abcde\n1234Xyz
1807     BarFoo 
1808     *** Failers 
1809     abcde\nBar  
1810
1811 /^.*B/
1812     **** Failers
1813     abc\nB
1814      
1815 /(?s)^.*B/
1816     abc\nB
1817
1818 /(?m)^.*B/
1819     abc\nB
1820      
1821 /(?ms)^.*B/
1822     abc\nB
1823
1824 /(?ms)^B/
1825     abc\nB
1826
1827 /(?s)B$/
1828     B\n
1829
1830 /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
1831     123456654321
1832   
1833 /^\d\d\d\d\d\d\d\d\d\d\d\d/
1834     123456654321 
1835
1836 /^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
1837     123456654321
1838   
1839 /^[abc]{12}/
1840     abcabcabcabc
1841     
1842 /^[a-c]{12}/
1843     abcabcabcabc
1844     
1845 /^(a|b|c){12}/
1846     abcabcabcabc 
1847
1848 /^[abcdefghijklmnopqrstuvwxy0123456789]/
1849     n
1850     *** Failers 
1851     z 
1852
1853 /abcde{0,0}/
1854     abcd
1855     *** Failers
1856     abce  
1857
1858 /ab[cd]{0,0}e/
1859     abe
1860     *** Failers
1861     abcde 
1862     
1863 /ab(c){0,0}d/
1864     abd
1865     *** Failers
1866     abcd   
1867
1868 /a(b*)/
1869     a
1870     ab
1871     abbbb
1872     *** Failers
1873     bbbbb    
1874     
1875 /ab\d{0}e/
1876     abe
1877     *** Failers
1878     ab1e   
1879     
1880 /"([^\\"]+|\\.)*"/
1881     the \"quick\" brown fox
1882     \"the \\\"quick\\\" brown fox\" 
1883
1884 /.*?/g+
1885     abc
1886   
1887 /\b/g+
1888     abc 
1889
1890 /\b/+g
1891     abc 
1892
1893 //g
1894     abc
1895
1896 /<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
1897   <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>
1898
1899 /a[^a]b/
1900     acb
1901     a\nb
1902     
1903 /a.b/
1904     acb
1905     *** Failers 
1906     a\nb   
1907     
1908 /a[^a]b/s
1909     acb
1910     a\nb  
1911     
1912 /a.b/s
1913     acb
1914     a\nb  
1915
1916 /^(b+?|a){1,2}?c/
1917     bac
1918     bbac
1919     bbbac
1920     bbbbac
1921     bbbbbac 
1922
1923 /^(b+|a){1,2}?c/
1924     bac
1925     bbac
1926     bbbac
1927     bbbbac
1928     bbbbbac 
1929     
1930 /(?!\A)x/m
1931     x\nb\n
1932     a\bx\n  
1933     
1934 /\x0{ab}/
1935     \0{ab} 
1936
1937 /(A|B)*?CD/
1938     CD 
1939     
1940 /(A|B)*CD/
1941     CD 
1942
1943 /(AB)*?\1/
1944     ABABAB
1945
1946 /(AB)*\1/
1947     ABABAB
1948     
1949 /(?<!bar)foo/
1950     foo
1951     catfood
1952     arfootle
1953     rfoosh
1954     *** Failers
1955     barfoo
1956     towbarfoo
1957
1958 /\w{3}(?<!bar)foo/
1959     catfood
1960     *** Failers
1961     foo
1962     barfoo
1963     towbarfoo
1964
1965 /(?<=(foo)a)bar/
1966     fooabar
1967     *** Failers
1968     bar
1969     foobbar
1970       
1971 /\Aabc\z/m
1972     abc
1973     *** Failers
1974     abc\n   
1975     qqq\nabc
1976     abc\nzzz
1977     qqq\nabc\nzzz
1978
1979 "(?>.*/)foo"
1980     /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
1981
1982 "(?>.*/)foo"
1983     /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
1984
1985 /(?>(\.\d\d[1-9]?))\d+/
1986     1.230003938
1987     1.875000282
1988     *** Failers 
1989     1.235 
1990
1991 /^((?>\w+)|(?>\s+))*$/
1992     now is the time for all good men to come to the aid of the party
1993     *** Failers
1994     this is not a line with only words and spaces!
1995     
1996 /(\d+)(\w)/
1997     12345a
1998     12345+ 
1999
2000 /((?>\d+))(\w)/
2001     12345a
2002     *** Failers
2003     12345+ 
2004
2005 /(?>a+)b/
2006     aaab
2007
2008 /((?>a+)b)/
2009     aaab
2010
2011 /(?>(a+))b/
2012     aaab
2013
2014 /(?>b)+/
2015     aaabbbccc
2016
2017 /(?>a+|b+|c+)*c/
2018     aaabbbbccccd
2019
2020 /((?>[^()]+)|\([^()]*\))+/
2021     ((abc(ade)ufh()()x
2022     
2023 /\(((?>[^()]+)|\([^()]+\))+\)/ 
2024     (abc)
2025     (abc(def)xyz)
2026     *** Failers
2027     ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa   
2028
2029 /a(?-i)b/i
2030     ab
2031     Ab
2032     *** Failers 
2033     aB
2034     AB
2035         
2036 /(a (?x)b c)d e/
2037     a bcd e
2038     *** Failers
2039     a b cd e
2040     abcd e   
2041     a bcde 
2042  
2043 /(a b(?x)c d (?-x)e f)/
2044     a bcde f
2045     *** Failers
2046     abcdef  
2047
2048 /(a(?i)b)c/
2049     abc
2050     aBc
2051     *** Failers
2052     abC
2053     aBC  
2054     Abc
2055     ABc
2056     ABC
2057     AbC
2058     
2059 /a(?i:b)c/
2060     abc
2061     aBc
2062     *** Failers 
2063     ABC
2064     abC
2065     aBC
2066     
2067 /a(?i:b)*c/
2068     aBc
2069     aBBc
2070     *** Failers 
2071     aBC
2072     aBBC
2073     
2074 /a(?=b(?i)c)\w\wd/
2075     abcd
2076     abCd
2077     *** Failers
2078     aBCd
2079     abcD     
2080     
2081 /(?s-i:more.*than).*million/i
2082     more than million
2083     more than MILLION
2084     more \n than Million 
2085     *** Failers
2086     MORE THAN MILLION    
2087     more \n than \n million 
2088
2089 /(?:(?s-i)more.*than).*million/i
2090     more than million
2091     more than MILLION
2092     more \n than Million 
2093     *** Failers
2094     MORE THAN MILLION    
2095     more \n than \n million 
2096     
2097 /(?>a(?i)b+)+c/ 
2098     abc
2099     aBbc
2100     aBBc 
2101     *** Failers
2102     Abc
2103     abAb    
2104     abbC 
2105     
2106 /(?=a(?i)b)\w\wc/
2107     abc
2108     aBc
2109     *** Failers
2110     Ab 
2111     abC
2112     aBC     
2113     
2114 /(?<=a(?i)b)(\w\w)c/
2115     abxxc
2116     aBxxc
2117     *** Failers
2118     Abxxc
2119     ABxxc
2120     abxxC      
2121
2122 /(?:(a)|b)(?(1)A|B)/
2123     aA
2124     bB
2125     *** Failers
2126     aB
2127     bA    
2128
2129 /^(a)?(?(1)a|b)+$/
2130     aa
2131     b
2132     bb  
2133     *** Failers
2134     ab   
2135
2136 /^(?(?=abc)\w{3}:|\d\d)$/
2137     abc:
2138     12
2139     *** Failers
2140     123
2141     xyz    
2142
2143 /^(?(?!abc)\d\d|\w{3}:)$/
2144     abc:
2145     12
2146     *** Failers
2147     123
2148     xyz    
2149     
2150 /(?(?<=foo)bar|cat)/
2151     foobar
2152     cat
2153     fcat
2154     focat   
2155     *** Failers
2156     foocat  
2157
2158 /(?(?<!foo)cat|bar)/
2159     foobar
2160     cat
2161     fcat
2162     focat   
2163     *** Failers
2164     foocat  
2165
2166 /( \( )? [^()]+ (?(1) \) |) /x
2167     abcd
2168     (abcd)
2169     the quick (abcd) fox
2170     (abcd   
2171
2172 /( \( )? [^()]+ (?(1) \) ) /x
2173     abcd
2174     (abcd)
2175     the quick (abcd) fox
2176     (abcd   
2177
2178 /^(?(2)a|(1)(2))+$/
2179     12
2180     12a
2181     12aa
2182     *** Failers
2183     1234    
2184
2185 /((?i)blah)\s+\1/
2186     blah blah
2187     BLAH BLAH
2188     Blah Blah
2189     blaH blaH
2190     *** Failers
2191     blah BLAH
2192     Blah blah      
2193     blaH blah 
2194
2195 /((?i)blah)\s+(?i:\1)/
2196     blah blah
2197     BLAH BLAH
2198     Blah Blah
2199     blaH blaH
2200     blah BLAH
2201     Blah blah      
2202     blaH blah 
2203
2204 /(?>a*)*/
2205     a
2206     aa
2207     aaaa
2208     
2209 /(abc|)+/
2210     abc
2211     abcabc
2212     abcabcabc
2213     xyz      
2214
2215 /([a]*)*/
2216     a
2217     aaaaa 
2218  
2219 /([ab]*)*/
2220     a
2221     b
2222     ababab
2223     aaaabcde
2224     bbbb    
2225  
2226 /([^a]*)*/
2227     b
2228     bbbb
2229     aaa   
2230  
2231 /([^ab]*)*/
2232     cccc
2233     abab  
2234  
2235 /([a]*?)*/
2236     a
2237     aaaa 
2238  
2239 /([ab]*?)*/
2240     a
2241     b
2242     abab
2243     baba   
2244  
2245 /([^a]*?)*/
2246     b
2247     bbbb
2248     aaa   
2249  
2250 /([^ab]*?)*/
2251     c
2252     cccc
2253     baba   
2254  
2255 /(?>a*)*/
2256     a
2257     aaabcde 
2258  
2259 /((?>a*))*/
2260     aaaaa
2261     aabbaa 
2262  
2263 /((?>a*?))*/
2264     aaaaa
2265     aabbaa 
2266
2267 /(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /x
2268     12-sep-98
2269     12-09-98
2270     *** Failers
2271     sep-12-98
2272         
2273 /(?<=(foo))bar\1/
2274     foobarfoo
2275     foobarfootling 
2276     *** Failers
2277     foobar
2278     barfoo   
2279
2280 /(?i:saturday|sunday)/
2281     saturday
2282     sunday
2283     Saturday
2284     Sunday
2285     SATURDAY
2286     SUNDAY
2287     SunDay
2288     
2289 /(a(?i)bc|BB)x/
2290     abcx
2291     aBCx
2292     bbx
2293     BBx
2294     *** Failers
2295     abcX
2296     aBCX
2297     bbX
2298     BBX               
2299
2300 /^([ab](?i)[cd]|[ef])/
2301     ac
2302     aC
2303     bD
2304     elephant
2305     Europe 
2306     frog
2307     France
2308     *** Failers
2309     Africa     
2310
2311 /^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
2312     ab
2313     aBd
2314     xy
2315     xY
2316     zebra
2317     Zambesi
2318     *** Failers
2319     aCD  
2320     XY  
2321
2322 /(?<=foo\n)^bar/m
2323     foo\nbar
2324     *** Failers
2325     bar
2326     baz\nbar   
2327
2328 /(?<=(?<!foo)bar)baz/
2329     barbaz
2330     barbarbaz 
2331     koobarbaz 
2332     *** Failers
2333     baz
2334     foobarbaz 
2335
2336 /The cases of aaaa and aaaaaa are missed out below because Perl does things/
2337 /differently. We know that odd, and maybe incorrect, things happen with/
2338 /recursive references in Perl, as far as 5.11.3 - see some stuff in test #2./
2339
2340 /^(a\1?){4}$/
2341     a
2342     aa
2343     aaa
2344     aaaaa
2345     aaaaaaa
2346     aaaaaaaa
2347     aaaaaaaaa
2348     aaaaaaaaaa
2349     aaaaaaaaaaa
2350     aaaaaaaaaaaa
2351     aaaaaaaaaaaaa
2352     aaaaaaaaaaaaaa
2353     aaaaaaaaaaaaaaa
2354     aaaaaaaaaaaaaaaa               
2355
2356 /^(a\1?)(a\1?)(a\2?)(a\3?)$/
2357     a
2358     aa
2359     aaa
2360     aaaa
2361     aaaaa
2362     aaaaaa
2363     aaaaaaa
2364     aaaaaaaa
2365     aaaaaaaaa
2366     aaaaaaaaaa
2367     aaaaaaaaaaa
2368     aaaaaaaaaaaa
2369     aaaaaaaaaaaaa
2370     aaaaaaaaaaaaaa
2371     aaaaaaaaaaaaaaa
2372     aaaaaaaaaaaaaaaa               
2373
2374 /The following tests are taken from the Perl 5.005 test suite; some of them/
2375 /are compatible with 5.004, but I'd rather not have to sort them out./
2376
2377 /abc/
2378     abc
2379     xabcy
2380     ababc
2381     *** Failers
2382     xbc
2383     axc
2384     abx
2385
2386 /ab*c/
2387     abc
2388
2389 /ab*bc/
2390     abc
2391     abbc
2392     abbbbc
2393
2394 /.{1}/
2395     abbbbc
2396
2397 /.{3,4}/
2398     abbbbc
2399
2400 /ab{0,}bc/
2401     abbbbc
2402
2403 /ab+bc/
2404     abbc
2405     *** Failers
2406     abc
2407     abq
2408
2409 /ab{1,}bc/
2410
2411 /ab+bc/
2412     abbbbc
2413
2414 /ab{1,}bc/
2415     abbbbc
2416
2417 /ab{1,3}bc/
2418     abbbbc
2419
2420 /ab{3,4}bc/
2421     abbbbc
2422
2423 /ab{4,5}bc/
2424     *** Failers
2425     abq
2426     abbbbc
2427
2428 /ab?bc/
2429     abbc
2430     abc
2431
2432 /ab{0,1}bc/
2433     abc
2434
2435 /ab?bc/
2436
2437 /ab?c/
2438     abc
2439
2440 /ab{0,1}c/
2441     abc
2442
2443 /^abc$/
2444     abc
2445     *** Failers
2446     abbbbc
2447     abcc
2448
2449 /^abc/
2450     abcc
2451
2452 /^abc$/
2453
2454 /abc$/
2455     aabc
2456     *** Failers
2457     aabc
2458     aabcd
2459
2460 /^/
2461     abc
2462
2463 /$/
2464     abc
2465
2466 /a.c/
2467     abc
2468     axc
2469
2470 /a.*c/
2471     axyzc
2472
2473 /a[bc]d/
2474     abd
2475     *** Failers
2476     axyzd
2477     abc
2478
2479 /a[b-d]e/
2480     ace
2481
2482 /a[b-d]/
2483     aac
2484
2485 /a[-b]/
2486     a-
2487
2488 /a[b-]/
2489     a-
2490
2491 /a]/
2492     a]
2493
2494 /a[]]b/
2495     a]b
2496
2497 /a[^bc]d/
2498     aed
2499     *** Failers
2500     abd
2501     abd
2502
2503 /a[^-b]c/
2504     adc
2505
2506 /a[^]b]c/
2507     adc
2508     *** Failers
2509     a-c
2510     a]c
2511
2512 /\ba\b/
2513     a-
2514     -a
2515     -a-
2516
2517 /\by\b/
2518     *** Failers
2519     xy
2520     yz
2521     xyz
2522
2523 /\Ba\B/
2524     *** Failers
2525     a-
2526     -a
2527     -a-
2528
2529 /\By\b/
2530     xy
2531
2532 /\by\B/
2533     yz
2534
2535 /\By\B/
2536     xyz
2537
2538 /\w/
2539     a
2540
2541 /\W/
2542     -
2543     *** Failers
2544     -
2545     a
2546
2547 /a\sb/
2548     a b
2549
2550 /a\Sb/
2551     a-b
2552     *** Failers
2553     a-b
2554     a b
2555
2556 /\d/
2557     1
2558
2559 /\D/
2560     -
2561     *** Failers
2562     -
2563     1
2564
2565 /[\w]/
2566     a
2567
2568 /[\W]/
2569     -
2570     *** Failers
2571     -
2572     a
2573
2574 /a[\s]b/
2575     a b
2576
2577 /a[\S]b/
2578     a-b
2579     *** Failers
2580     a-b
2581     a b
2582
2583 /[\d]/
2584     1
2585
2586 /[\D]/
2587     -
2588     *** Failers
2589     -
2590     1
2591
2592 /ab|cd/
2593     abc
2594     abcd
2595
2596 /()ef/
2597     def
2598
2599 /$b/
2600
2601 /a\(b/
2602     a(b
2603
2604 /a\(*b/
2605     ab
2606     a((b
2607
2608 /a\\b/
2609     a\b
2610
2611 /((a))/
2612     abc
2613
2614 /(a)b(c)/
2615     abc
2616
2617 /a+b+c/
2618     aabbabc
2619
2620 /a{1,}b{1,}c/
2621     aabbabc
2622
2623 /a.+?c/
2624     abcabc
2625
2626 /(a+|b)*/
2627     ab
2628
2629 /(a+|b){0,}/
2630     ab
2631
2632 /(a+|b)+/
2633     ab
2634
2635 /(a+|b){1,}/
2636     ab
2637
2638 /(a+|b)?/
2639     ab
2640
2641 /(a+|b){0,1}/
2642     ab
2643
2644 /[^ab]*/
2645     cde
2646
2647 /abc/
2648     *** Failers
2649     b
2650     
2651
2652 /a*/
2653     
2654
2655 /([abc])*d/
2656     abbbcd
2657
2658 /([abc])*bcd/
2659     abcd
2660
2661 /a|b|c|d|e/
2662     e
2663
2664 /(a|b|c|d|e)f/
2665     ef
2666
2667 /abcd*efg/
2668     abcdefg
2669
2670 /ab*/
2671     xabyabbbz
2672     xayabbbz
2673
2674 /(ab|cd)e/
2675     abcde
2676
2677 /[abhgefdc]ij/
2678     hij
2679
2680 /^(ab|cd)e/
2681
2682 /(abc|)ef/
2683     abcdef
2684
2685 /(a|b)c*d/
2686     abcd
2687
2688 /(ab|ab*)bc/
2689     abc
2690
2691 /a([bc]*)c*/
2692     abc
2693
2694 /a([bc]*)(c*d)/
2695     abcd
2696
2697 /a([bc]+)(c*d)/
2698     abcd
2699
2700 /a([bc]*)(c+d)/
2701     abcd
2702
2703 /a[bcd]*dcdcde/
2704     adcdcde
2705
2706 /a[bcd]+dcdcde/
2707     *** Failers
2708     abcde
2709     adcdcde
2710
2711 /(ab|a)b*c/
2712     abc
2713
2714 /((a)(b)c)(d)/
2715     abcd
2716
2717 /[a-zA-Z_][a-zA-Z0-9_]*/
2718     alpha
2719
2720 /^a(bc+|b[eh])g|.h$/
2721     abh
2722
2723 /(bc+d$|ef*g.|h?i(j|k))/
2724     effgz
2725     ij
2726     reffgz
2727     *** Failers
2728     effg
2729     bcdd
2730
2731 /((((((((((a))))))))))/
2732     a
2733
2734 /((((((((((a))))))))))\10/
2735     aa
2736
2737 /(((((((((a)))))))))/
2738     a
2739
2740 /multiple words of text/
2741     *** Failers
2742     aa
2743     uh-uh
2744
2745 /multiple words/
2746     multiple words, yeah
2747
2748 /(.*)c(.*)/
2749     abcde
2750
2751 /\((.*), (.*)\)/
2752     (a, b)
2753
2754 /[k]/
2755
2756 /abcd/
2757     abcd
2758
2759 /a(bc)d/
2760     abcd
2761
2762 /a[-]?c/
2763     ac
2764
2765 /(abc)\1/
2766     abcabc
2767
2768 /([a-c]*)\1/
2769     abcabc
2770
2771 /(a)|\1/
2772     a
2773     *** Failers
2774     ab
2775     x
2776
2777 /(([a-c])b*?\2)*/
2778     ababbbcbc
2779
2780 /(([a-c])b*?\2){3}/
2781     ababbbcbc
2782
2783 /((\3|b)\2(a)x)+/
2784     aaaxabaxbaaxbbax
2785
2786 /((\3|b)\2(a)){2,}/
2787     bbaababbabaaaaabbaaaabba
2788
2789 /abc/i
2790     ABC
2791     XABCY
2792     ABABC
2793     *** Failers
2794     aaxabxbaxbbx
2795     XBC
2796     AXC
2797     ABX
2798
2799 /ab*c/i
2800     ABC
2801
2802 /ab*bc/i
2803     ABC
2804     ABBC
2805
2806 /ab*?bc/i
2807     ABBBBC
2808
2809 /ab{0,}?bc/i
2810     ABBBBC
2811
2812 /ab+?bc/i
2813     ABBC
2814
2815 /ab+bc/i
2816     *** Failers
2817     ABC
2818     ABQ
2819
2820 /ab{1,}bc/i
2821
2822 /ab+bc/i
2823     ABBBBC
2824
2825 /ab{1,}?bc/i
2826     ABBBBC
2827
2828 /ab{1,3}?bc/i
2829     ABBBBC
2830
2831 /ab{3,4}?bc/i
2832     ABBBBC
2833
2834 /ab{4,5}?bc/i
2835     *** Failers
2836     ABQ
2837     ABBBBC
2838
2839 /ab??bc/i
2840     ABBC
2841     ABC
2842
2843 /ab{0,1}?bc/i
2844     ABC
2845
2846 /ab??bc/i
2847
2848 /ab??c/i
2849     ABC
2850
2851 /ab{0,1}?c/i
2852     ABC
2853
2854 /^abc$/i
2855     ABC
2856     *** Failers
2857     ABBBBC
2858     ABCC
2859
2860 /^abc/i
2861     ABCC
2862
2863 /^abc$/i
2864
2865 /abc$/i
2866     AABC
2867
2868 /^/i
2869     ABC
2870
2871 /$/i
2872     ABC
2873
2874 /a.c/i
2875     ABC
2876     AXC
2877
2878 /a.*?c/i
2879     AXYZC
2880
2881 /a.*c/i
2882     *** Failers
2883     AABC
2884     AXYZD
2885
2886 /a[bc]d/i
2887     ABD
2888
2889 /a[b-d]e/i
2890     ACE
2891     *** Failers
2892     ABC
2893     ABD
2894
2895 /a[b-d]/i
2896     AAC
2897
2898 /a[-b]/i
2899     A-
2900
2901 /a[b-]/i
2902     A-
2903
2904 /a]/i
2905     A]
2906
2907 /a[]]b/i
2908     A]B
2909
2910 /a[^bc]d/i
2911     AED
2912
2913 /a[^-b]c/i
2914     ADC
2915     *** Failers
2916     ABD
2917     A-C
2918
2919 /a[^]b]c/i
2920     ADC
2921
2922 /ab|cd/i
2923     ABC
2924     ABCD
2925
2926 /()ef/i
2927     DEF
2928
2929 /$b/i
2930     *** Failers
2931     A]C
2932     B
2933
2934 /a\(b/i
2935     A(B
2936
2937 /a\(*b/i
2938     AB
2939     A((B
2940
2941 /a\\b/i
2942     A\B
2943
2944 /((a))/i
2945     ABC
2946
2947 /(a)b(c)/i
2948     ABC
2949
2950 /a+b+c/i
2951     AABBABC
2952
2953 /a{1,}b{1,}c/i
2954     AABBABC
2955
2956 /a.+?c/i
2957     ABCABC
2958
2959 /a.*?c/i
2960     ABCABC
2961
2962 /a.{0,5}?c/i
2963     ABCABC
2964
2965 /(a+|b)*/i
2966     AB
2967
2968 /(a+|b){0,}/i
2969     AB
2970
2971 /(a+|b)+/i
2972     AB
2973
2974 /(a+|b){1,}/i
2975     AB
2976
2977 /(a+|b)?/i
2978     AB
2979
2980 /(a+|b){0,1}/i
2981     AB
2982
2983 /(a+|b){0,1}?/i
2984     AB
2985
2986 /[^ab]*/i
2987     CDE
2988
2989 /abc/i
2990
2991 /a*/i
2992     
2993
2994 /([abc])*d/i
2995     ABBBCD
2996
2997 /([abc])*bcd/i
2998     ABCD
2999
3000 /a|b|c|d|e/i
3001     E
3002
3003 /(a|b|c|d|e)f/i
3004     EF
3005
3006 /abcd*efg/i
3007     ABCDEFG
3008
3009 /ab*/i
3010     XABYABBBZ
3011     XAYABBBZ
3012
3013 /(ab|cd)e/i
3014     ABCDE
3015
3016 /[abhgefdc]ij/i
3017     HIJ
3018
3019 /^(ab|cd)e/i
3020     ABCDE
3021
3022 /(abc|)ef/i
3023     ABCDEF
3024
3025 /(a|b)c*d/i
3026     ABCD
3027
3028 /(ab|ab*)bc/i
3029     ABC
3030
3031 /a([bc]*)c*/i
3032     ABC
3033
3034 /a([bc]*)(c*d)/i
3035     ABCD
3036
3037 /a([bc]+)(c*d)/i
3038     ABCD
3039
3040 /a([bc]*)(c+d)/i
3041     ABCD
3042
3043 /a[bcd]*dcdcde/i
3044     ADCDCDE
3045
3046 /a[bcd]+dcdcde/i
3047
3048 /(ab|a)b*c/i
3049     ABC
3050
3051 /((a)(b)c)(d)/i
3052     ABCD
3053
3054 /[a-zA-Z_][a-zA-Z0-9_]*/i
3055     ALPHA
3056
3057 /^a(bc+|b[eh])g|.h$/i
3058     ABH
3059
3060 /(bc+d$|ef*g.|h?i(j|k))/i
3061     EFFGZ
3062     IJ
3063     REFFGZ
3064     *** Failers
3065     ADCDCDE
3066     EFFG
3067     BCDD
3068
3069 /((((((((((a))))))))))/i
3070     A
3071
3072 /((((((((((a))))))))))\10/i
3073     AA
3074
3075 /(((((((((a)))))))))/i
3076     A
3077
3078 /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
3079     A
3080
3081 /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
3082     C
3083
3084 /multiple words of text/i
3085     *** Failers
3086     AA
3087     UH-UH
3088
3089 /multiple words/i
3090     MULTIPLE WORDS, YEAH
3091
3092 /(.*)c(.*)/i
3093     ABCDE
3094
3095 /\((.*), (.*)\)/i
3096     (A, B)
3097
3098 /[k]/i
3099
3100 /abcd/i
3101     ABCD
3102
3103 /a(bc)d/i
3104     ABCD
3105
3106 /a[-]?c/i
3107     AC
3108
3109 /(abc)\1/i
3110     ABCABC
3111
3112 /([a-c]*)\1/i
3113     ABCABC
3114
3115 /a(?!b)./
3116     abad
3117
3118 /a(?=d)./
3119     abad
3120
3121 /a(?=c|d)./
3122     abad
3123
3124 /a(?:b|c|d)(.)/
3125     ace
3126
3127 /a(?:b|c|d)*(.)/
3128     ace
3129
3130 /a(?:b|c|d)+?(.)/
3131     ace
3132     acdbcdbe
3133
3134 /a(?:b|c|d)+(.)/
3135     acdbcdbe
3136
3137 /a(?:b|c|d){2}(.)/
3138     acdbcdbe
3139
3140 /a(?:b|c|d){4,5}(.)/
3141     acdbcdbe
3142
3143 /a(?:b|c|d){4,5}?(.)/
3144     acdbcdbe
3145
3146 /((foo)|(bar))*/
3147     foobar
3148
3149 /a(?:b|c|d){6,7}(.)/
3150     acdbcdbe
3151
3152 /a(?:b|c|d){6,7}?(.)/
3153     acdbcdbe
3154
3155 /a(?:b|c|d){5,6}(.)/
3156     acdbcdbe
3157
3158 /a(?:b|c|d){5,6}?(.)/
3159     acdbcdbe
3160
3161 /a(?:b|c|d){5,7}(.)/
3162     acdbcdbe
3163
3164 /a(?:b|c|d){5,7}?(.)/
3165     acdbcdbe
3166
3167 /a(?:b|(c|e){1,2}?|d)+?(.)/
3168     ace
3169
3170 /^(.+)?B/
3171     AB
3172
3173 /^([^a-z])|(\^)$/
3174     .
3175
3176 /^[<>]&/
3177     <&OUT
3178
3179 /^(a\1?){4}$/
3180     aaaaaaaaaa
3181     *** Failers
3182     AB
3183     aaaaaaaaa
3184     aaaaaaaaaaa
3185
3186 /^(a(?(1)\1)){4}$/
3187     aaaaaaaaaa
3188     *** Failers
3189     aaaaaaaaa
3190     aaaaaaaaaaa
3191
3192 /(?:(f)(o)(o)|(b)(a)(r))*/
3193     foobar
3194
3195 /(?<=a)b/
3196     ab
3197     *** Failers
3198     cb
3199     b
3200
3201 /(?<!c)b/
3202     ab
3203     b
3204     b
3205
3206 /(?:..)*a/
3207     aba
3208
3209 /(?:..)*?a/
3210     aba
3211
3212 /^(?:b|a(?=(.)))*\1/
3213     abc
3214
3215 /^(){3,5}/
3216     abc
3217
3218 /^(a+)*ax/
3219     aax
3220
3221 /^((a|b)+)*ax/
3222     aax
3223
3224 /^((a|bc)+)*ax/
3225     aax
3226
3227 /(a|x)*ab/
3228     cab
3229
3230 /(a)*ab/
3231     cab
3232
3233 /(?:(?i)a)b/
3234     ab
3235
3236 /((?i)a)b/
3237     ab
3238
3239 /(?:(?i)a)b/
3240     Ab
3241
3242 /((?i)a)b/
3243     Ab
3244
3245 /(?:(?i)a)b/
3246     *** Failers
3247     cb
3248     aB
3249
3250 /((?i)a)b/
3251
3252 /(?i:a)b/
3253     ab
3254
3255 /((?i:a))b/
3256     ab
3257
3258 /(?i:a)b/
3259     Ab
3260
3261 /((?i:a))b/
3262     Ab
3263
3264 /(?i:a)b/
3265     *** Failers
3266     aB
3267     aB
3268
3269 /((?i:a))b/
3270
3271 /(?:(?-i)a)b/i
3272     ab
3273
3274 /((?-i)a)b/i
3275     ab
3276
3277 /(?:(?-i)a)b/i
3278     aB
3279
3280 /((?-i)a)b/i
3281     aB
3282
3283 /(?:(?-i)a)b/i
3284     *** Failers
3285     aB
3286     Ab
3287
3288 /((?-i)a)b/i
3289
3290 /(?:(?-i)a)b/i
3291     aB
3292
3293 /((?-i)a)b/i
3294     aB
3295
3296 /(?:(?-i)a)b/i
3297     *** Failers
3298     Ab
3299     AB
3300
3301 /((?-i)a)b/i
3302
3303 /(?-i:a)b/i
3304     ab
3305
3306 /((?-i:a))b/i
3307     ab
3308
3309 /(?-i:a)b/i
3310     aB
3311
3312 /((?-i:a))b/i
3313     aB
3314
3315 /(?-i:a)b/i
3316     *** Failers
3317     AB
3318     Ab
3319
3320 /((?-i:a))b/i
3321
3322 /(?-i:a)b/i
3323     aB
3324
3325 /((?-i:a))b/i
3326     aB
3327
3328 /(?-i:a)b/i
3329     *** Failers
3330     Ab
3331     AB
3332
3333 /((?-i:a))b/i
3334
3335 /((?-i:a.))b/i
3336     *** Failers
3337     AB
3338     a\nB
3339
3340 /((?s-i:a.))b/i
3341     a\nB
3342
3343 /(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
3344     cabbbb
3345
3346 /(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
3347     caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
3348
3349 /(ab)\d\1/i
3350     Ab4ab
3351     ab4Ab
3352
3353 /foo\w*\d{4}baz/
3354     foobar1234baz
3355
3356 /x(~~)*(?:(?:F)?)?/
3357     x~~
3358
3359 /^a(?#xxx){3}c/
3360     aaac
3361
3362 /^a (?#xxx) (?#yyy) {3}c/x
3363     aaac
3364
3365 /(?<![cd])b/
3366     *** Failers
3367     B\nB
3368     dbcb
3369
3370 /(?<![cd])[ab]/
3371     dbaacb
3372
3373 /(?<!(c|d))b/
3374
3375 /(?<!(c|d))[ab]/
3376     dbaacb
3377
3378 /(?<!cd)[ab]/
3379     cdaccb
3380
3381 /^(?:a?b?)*$/
3382     \
3383     a
3384     ab
3385     aaa   
3386     *** Failers
3387     dbcb
3388     a--
3389     aa-- 
3390
3391 /((?s)^a(.))((?m)^b$)/
3392     a\nb\nc\n
3393
3394 /((?m)^b$)/
3395     a\nb\nc\n
3396
3397 /(?m)^b/
3398     a\nb\n
3399
3400 /(?m)^(b)/
3401     a\nb\n
3402
3403 /((?m)^b)/
3404     a\nb\n
3405
3406 /\n((?m)^b)/
3407     a\nb\n
3408
3409 /((?s).)c(?!.)/
3410     a\nb\nc\n
3411     a\nb\nc\n
3412
3413 /((?s)b.)c(?!.)/
3414     a\nb\nc\n
3415     a\nb\nc\n
3416
3417 /^b/
3418
3419 /()^b/
3420     *** Failers
3421     a\nb\nc\n
3422     a\nb\nc\n
3423
3424 /((?m)^b)/
3425     a\nb\nc\n
3426
3427 /(x)?(?(1)a|b)/
3428     *** Failers
3429     a
3430     a
3431
3432 /(x)?(?(1)b|a)/
3433     a
3434
3435 /()?(?(1)b|a)/
3436     a
3437
3438 /()(?(1)b|a)/
3439
3440 /()?(?(1)a|b)/
3441     a
3442
3443 /^(\()?blah(?(1)(\)))$/
3444     (blah)
3445     blah
3446     *** Failers
3447     a
3448     blah)
3449     (blah
3450
3451 /^(\(+)?blah(?(1)(\)))$/
3452     (blah)
3453     blah
3454     *** Failers
3455     blah)
3456     (blah
3457
3458 /(?(?!a)a|b)/
3459
3460 /(?(?!a)b|a)/
3461     a
3462
3463 /(?(?=a)b|a)/
3464     *** Failers
3465     a
3466     a
3467
3468 /(?(?=a)a|b)/
3469     a
3470
3471 /(?=(a+?))(\1ab)/
3472     aaab
3473
3474 /^(?=(a+?))\1ab/
3475
3476 /(\w+:)+/
3477     one:
3478
3479 /$(?<=^(a))/
3480     a
3481
3482 /(?=(a+?))(\1ab)/
3483     aaab
3484
3485 /^(?=(a+?))\1ab/
3486     *** Failers
3487     aaab
3488     aaab
3489
3490 /([\w:]+::)?(\w+)$/
3491     abcd
3492     xy:z:::abcd
3493
3494 /^[^bcd]*(c+)/
3495     aexycd
3496
3497 /(a*)b+/
3498     caab
3499
3500 /([\w:]+::)?(\w+)$/
3501     abcd
3502     xy:z:::abcd
3503     *** Failers
3504     abcd:
3505     abcd:
3506
3507 /^[^bcd]*(c+)/
3508     aexycd
3509
3510 /(>a+)ab/
3511
3512 /(?>a+)b/
3513     aaab
3514
3515 /([[:]+)/
3516     a:[b]:
3517
3518 /([[=]+)/
3519     a=[b]=
3520
3521 /([[.]+)/
3522     a.[b].
3523
3524 /((?>a+)b)/
3525     aaab
3526
3527 /(?>(a+))b/
3528     aaab
3529
3530 /((?>[^()]+)|\([^()]*\))+/
3531     ((abc(ade)ufh()()x
3532
3533 /a\Z/
3534     *** Failers
3535     aaab
3536     a\nb\n
3537
3538 /b\Z/
3539     a\nb\n
3540
3541 /b\z/
3542
3543 /b\Z/
3544     a\nb
3545
3546 /b\z/
3547     a\nb
3548     *** Failers
3549     
3550 /^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
3551     a
3552     abc
3553     a-b
3554     0-9 
3555     a.b
3556     5.6.7  
3557     the.quick.brown.fox
3558     a100.b200.300c  
3559     12-ab.1245 
3560     *** Failers
3561     \
3562     .a
3563     -a
3564     a-
3565     a.  
3566     a_b 
3567     a.-
3568     a..  
3569     ab..bc 
3570     the.quick.brown.fox-
3571     the.quick.brown.fox.
3572     the.quick.brown.fox_
3573     the.quick.brown.fox+       
3574
3575 /(?>.*)(?<=(abcd|wxyz))/
3576     alphabetabcd
3577     endingwxyz
3578     *** Failers
3579     a rather long string that doesn't end with one of them
3580
3581 /word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
3582     word cat dog elephant mussel cow horse canary baboon snake shark otherword
3583     word cat dog elephant mussel cow horse canary baboon snake shark
3584   
3585 /word (?>[a-zA-Z0-9]+ ){0,30}otherword/
3586     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
3587
3588 /(?<=\d{3}(?!999))foo/
3589     999foo
3590     123999foo 
3591     *** Failers
3592     123abcfoo
3593     
3594 /(?<=(?!...999)\d{3})foo/
3595     999foo
3596     123999foo 
3597     *** Failers
3598     123abcfoo
3599
3600 /(?<=\d{3}(?!999)...)foo/
3601     123abcfoo
3602     123456foo 
3603     *** Failers
3604     123999foo  
3605     
3606 /(?<=\d{3}...)(?<!999)foo/
3607     123abcfoo   
3608     123456foo 
3609     *** Failers
3610     123999foo  
3611
3612 /<a[\s]+href[\s]*=[\s]*          # find <a href=
3613  ([\"\'])?                       # find single or double quote
3614  (?(1) (.*?)\1 | ([^\s]+))       # if quote found, match up to next matching
3615                                  # quote, otherwise match up to next space
3616 /isx
3617     <a href=abcd xyz
3618     <a href=\"abcd xyz pqr\" cats
3619     <a href=\'abcd xyz pqr\' cats
3620
3621 /<a\s+href\s*=\s*                # find <a href=
3622  (["'])?                         # find single or double quote
3623  (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
3624                                  # quote, otherwise match up to next space
3625 /isx
3626     <a href=abcd xyz
3627     <a href=\"abcd xyz pqr\" cats
3628     <a href       =       \'abcd xyz pqr\' cats
3629
3630 /<a\s+href(?>\s*)=(?>\s*)        # find <a href=
3631  (["'])?                         # find single or double quote
3632  (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
3633                                  # quote, otherwise match up to next space
3634 /isx
3635     <a href=abcd xyz
3636     <a href=\"abcd xyz pqr\" cats
3637     <a href       =       \'abcd xyz pqr\' cats
3638
3639 /((Z)+|A)*/
3640     ZABCDEFG
3641
3642 /(Z()|A)*/
3643     ZABCDEFG
3644
3645 /(Z(())|A)*/
3646     ZABCDEFG
3647
3648 /((?>Z)+|A)*/
3649     ZABCDEFG
3650
3651 /((?>)+|A)*/
3652     ZABCDEFG
3653
3654 /a*/g
3655     abbab
3656
3657 /^[a-\d]/
3658     abcde
3659     -things
3660     0digit
3661     *** Failers
3662     bcdef    
3663
3664 /^[\d-a]/
3665     abcde
3666     -things
3667     0digit
3668     *** Failers
3669     bcdef    
3670     
3671 /[[:space:]]+/
3672     > \x09\x0a\x0c\x0d\x0b<
3673      
3674 /[[:blank:]]+/
3675     > \x09\x0a\x0c\x0d\x0b<
3676      
3677 /[\s]+/
3678     > \x09\x0a\x0c\x0d\x0b<
3679      
3680 /\s+/
3681     > \x09\x0a\x0c\x0d\x0b<
3682      
3683 /a\vb/x
3684     ab
3685
3686 /(?!\A)x/m
3687   a\nxb\n
3688
3689 /(?!^)x/m
3690   a\nxb\n
3691
3692 /abc\Qabc\Eabc/
3693     abcabcabc
3694     
3695 /abc\Q(*+|\Eabc/
3696     abc(*+|abc 
3697
3698 /   abc\Q abc\Eabc/x
3699     abc abcabc
3700     *** Failers
3701     abcabcabc  
3702     
3703 /abc#comment
3704     \Q#not comment
3705     literal\E/x
3706     abc#not comment\n    literal     
3707
3708 /abc#comment
3709     \Q#not comment
3710     literal/x
3711     abc#not comment\n    literal     
3712
3713 /abc#comment
3714     \Q#not comment
3715     literal\E #more comment
3716     /x
3717     abc#not comment\n    literal     
3718
3719 /abc#comment
3720     \Q#not comment
3721     literal\E #more comment/x
3722     abc#not comment\n    literal     
3723
3724 /\Qabc\$xyz\E/
3725     abc\\\$xyz
3726
3727 /\Qabc\E\$\Qxyz\E/
3728     abc\$xyz
3729
3730 /\Gabc/
3731     abc
3732     *** Failers
3733     xyzabc  
3734
3735 /\Gabc./g
3736     abc1abc2xyzabc3
3737
3738 /abc./g
3739     abc1abc2xyzabc3 
3740
3741 /a(?x: b c )d/
3742     XabcdY
3743     *** Failers 
3744     Xa b c d Y 
3745
3746 /((?x)x y z | a b c)/
3747     XabcY
3748     AxyzB 
3749
3750 /(?i)AB(?-i)C/
3751     XabCY
3752     *** Failers
3753     XabcY  
3754
3755 /((?i)AB(?-i)C|D)E/
3756     abCE
3757     DE
3758     *** Failers
3759     abcE
3760     abCe  
3761     dE
3762     De    
3763
3764 /(.*)\d+\1/
3765     abc123abc
3766     abc123bc 
3767
3768 /(.*)\d+\1/s
3769     abc123abc
3770     abc123bc 
3771     
3772 /((.*))\d+\1/
3773     abc123abc
3774     abc123bc  
3775
3776 /-- This tests for an IPv6 address in the form where it can have up to --/
3777 /-- eight components, one and only one of which is empty. This must be --/
3778 /-- an internal component. --/
3779
3780 /^(?!:)                       # colon disallowed at start
3781   (?:                         # start of item
3782     (?: [0-9a-f]{1,4} |       # 1-4 hex digits or
3783     (?(1)0 | () ) )           # if null previously matched, fail; else null
3784     :                         # followed by colon
3785   ){1,7}                      # end item; 1-7 of them required               
3786   [0-9a-f]{1,4} $             # final hex number at end of string
3787   (?(1)|.)                    # check that there was an empty component
3788   /xi
3789     a123::a123
3790     a123:b342::abcd
3791     a123:b342::324e:abcd
3792     a123:ddde:b342::324e:abcd
3793     a123:ddde:b342::324e:dcba:abcd
3794     a123:ddde:9999:b342::324e:dcba:abcd
3795     *** Failers
3796     1:2:3:4:5:6:7:8
3797     a123:bce:ddde:9999:b342::324e:dcba:abcd
3798     a123::9999:b342::324e:dcba:abcd
3799     abcde:2:3:4:5:6:7:8
3800     ::1
3801     abcd:fee0:123::   
3802     :1
3803     1:  
3804
3805 /[z\Qa-d]\E]/
3806     z
3807     a
3808     -
3809     d
3810     ] 
3811     *** Failers
3812     b     
3813
3814 /[\z\C]/
3815     z
3816     C 
3817     
3818 /\M/
3819     M 
3820     
3821 /(a+)*b/
3822     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
3823     
3824 /(?i)reg(?:ul(?:[aä]|ae)r|ex)/
3825     REGular
3826     regulaer
3827     Regex  
3828     regulär 
3829
3830 /Åæåä[à-ÿÀ-ß]+/
3831     Åæåäà
3832     Åæåäÿ
3833     ÅæåäÀ
3834     Åæåäß
3835
3836 /(?<=Z)X./
3837   \x84XAZXB
3838
3839 /ab cd (?x) de fg/
3840     ab cd defg
3841
3842 /ab cd(?x) de fg/
3843     ab cddefg
3844     ** Failers 
3845     abcddefg
3846
3847 /(?<![^f]oo)(bar)/
3848     foobarX 
3849     ** Failers 
3850     boobarX
3851
3852 /(?<![^f])X/
3853     offX
3854     ** Failers
3855     onyX  
3856
3857 /(?<=[^f])X/
3858     onyX
3859     ** Failers
3860     offX 
3861
3862 /^/mg
3863     a\nb\nc\n
3864     \ 
3865     
3866 /(?<=C\n)^/mg
3867     A\nC\nC\n 
3868
3869 /(?:(?(1)a|b)(X))+/
3870     bXaX
3871
3872 /(?:(?(1)\1a|b)(X|Y))+/
3873     bXXaYYaY
3874     bXYaXXaX  
3875
3876 /()()()()()()()()()(?:(?(10)\10a|b)(X|Y))+/
3877     bXXaYYaY
3878
3879 /[[,abc,]+]/
3880     abc]
3881     a,b]
3882     [a,b,c]  
3883
3884 /(?-x: )/x
3885     A\x20B
3886     
3887 "(?x)(?-x: \s*#\s*)"
3888     A # B
3889     ** Failers
3890     #  
3891
3892 "(?x-is)(?:(?-ixs) \s*#\s*) include"
3893     A #include
3894     ** Failers
3895     A#include  
3896     A #Include
3897
3898 /a*b*\w/
3899     aaabbbb
3900     aaaa
3901     a
3902
3903 /a*b?\w/
3904     aaabbbb
3905     aaaa
3906     a
3907
3908 /a*b{0,4}\w/
3909     aaabbbb
3910     aaaa
3911     a
3912
3913 /a*b{0,}\w/
3914     aaabbbb
3915     aaaa
3916     a
3917     
3918 /a*\d*\w/
3919     0a
3920     a 
3921     
3922 /a*b *\w/x
3923     a 
3924
3925 /a*b#comment
3926   *\w/x
3927     a 
3928
3929 /a* b *\w/x
3930     a 
3931
3932 /^\w+=.*(\\\n.*)*/
3933     abc=xyz\\\npqr
3934
3935 /(?=(\w+))\1:/
3936     abcd:
3937
3938 /^(?=(\w+))\1:/
3939     abcd:
3940
3941 /^\Eabc/
3942     abc
3943     
3944 /^[\Eabc]/
3945     a
3946     ** Failers 
3947     E 
3948     
3949 /^[a-\Ec]/
3950     b
3951     ** Failers
3952     -
3953     E    
3954
3955 /^[a\E\E-\Ec]/
3956     b
3957     ** Failers
3958     -
3959     E    
3960
3961 /^[\E\Qa\E-\Qz\E]+/
3962     b
3963     ** Failers
3964     -  
3965     
3966 /^[a\Q]bc\E]/
3967     a
3968     ]
3969     c
3970     
3971 /^[a-\Q\E]/
3972     a
3973     -     
3974
3975 /^(a()*)*/
3976     aaaa
3977
3978 /^(?:a(?:(?:))*)*/
3979     aaaa
3980
3981 /^(a()+)+/
3982     aaaa
3983
3984 /^(?:a(?:(?:))+)+/
3985     aaaa
3986
3987 /(a){0,3}(?(1)b|(c|))*D/
3988     abbD
3989     ccccD
3990     D  
3991
3992 /(a|)*\d/
3993   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
3994   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
3995
3996 /(?>a|)*\d/
3997   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
3998   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
3999
4000 /(?:a|)*\d/
4001   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
4002   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
4003
4004 /\Z/g
4005   abc\n
4006   
4007 /^(?s)(?>.*)(?<!\n)/
4008   abc
4009   abc\n  
4010
4011 /^(?![^\n]*\n\z)/
4012   abc
4013   abc\n 
4014   
4015 /\z(?<!\n)/
4016   abc
4017   abc\n  
4018
4019 /(.*(.)?)*/
4020     abcd
4021
4022 /( (A | (?(1)0|) )*   )/x
4023     abcd
4024
4025 /( ( (?(1)0|) )*   )/x
4026     abcd
4027
4028 /(  (?(1)0|)*   )/x
4029     abcd
4030
4031 /[[:abcd:xyz]]/
4032     a]
4033     :] 
4034     
4035 /[abc[:x\]pqr]/
4036     a
4037     [
4038     :
4039     ]
4040     p    
4041
4042 /.*[op][xyz]/
4043     fooabcfoo
4044
4045 /(?(?=.*b)b|^)/
4046    adc
4047    abc 
4048
4049 /(?(?=^.*b)b|^)/
4050    adc
4051    abc 
4052
4053 /(?(?=.*b)b|^)*/
4054    adc
4055    abc 
4056
4057 /(?(?=.*b)b|^)+/
4058    adc
4059    abc 
4060
4061 /(?(?=b).*b|^d)/
4062     abc
4063
4064 /(?(?=.*b).*b|^d)/
4065     abc
4066
4067 /^%((?(?=[a])[^%])|b)*%$/
4068     %ab%
4069
4070 /(?i)a(?-i)b|c/
4071     XabX
4072     XAbX
4073     CcC 
4074     ** Failers
4075     XABX   
4076
4077 /[\x00-\xff\s]+/
4078     \x0a\x0b\x0c\x0d
4079
4080 /^\c\7f/
4081     ?
4082
4083 /(abc)\1/i
4084    abc
4085
4086 /(abc)\1/
4087    abc
4088
4089 /[^a]*/i
4090     12abc
4091     12ABC
4092
4093 /[^a]*+/i
4094     12abc
4095     12ABC
4096
4097 /[^a]*?X/i
4098     ** Failers
4099     12abc
4100     12ABC
4101     
4102 /[^a]+?X/i   
4103     ** Failers
4104     12abc
4105     12ABC
4106
4107 /[^a]?X/i
4108     12aXbcX
4109     12AXBCX
4110     BCX 
4111
4112 /[^a]??X/i
4113     12aXbcX
4114     12AXBCX
4115     BCX
4116     
4117 /[^a]?+X/i
4118     12aXbcX
4119     12AXBCX
4120     BCX 
4121
4122 /[^a]{2,3}/i
4123     abcdef
4124     ABCDEF  
4125
4126 /[^a]{2,3}?/i
4127     abcdef
4128     ABCDEF  
4129
4130 /[^a]{2,3}+/i
4131     abcdef
4132     ABCDEF  
4133
4134 /((a|)+)+Z/
4135     Z
4136
4137 /(a)b|(a)c/
4138     ac
4139
4140 /(?>(a))b|(a)c/
4141     ac
4142
4143 /(?=(a))ab|(a)c/
4144     ac
4145
4146 /((?>(a))b|(a)c)/
4147     ac
4148
4149 /((?>(a))b|(a)c)++/
4150     ac
4151
4152 /(?:(?>(a))b|(a)c)++/
4153     ac
4154
4155 /(?=(?>(a))b|(a)c)(..)/
4156     ac
4157
4158 /(?>(?>(a))b|(a)c)/
4159     ac
4160
4161 /(?:(?>([ab])))+a=/+
4162     =ba=
4163
4164 /(?>([ab]))+a=/+
4165     =ba=
4166
4167 /((?>(a+)b)+(aabab))/
4168     aaaabaaabaabab
4169
4170 /(?>a+|ab)+?c/
4171     aabc
4172
4173 /(?>a+|ab)+c/
4174     aabc
4175
4176 /(?:a+|ab)+c/
4177     aabc
4178
4179 /(?(?=(a))a)/
4180     a
4181
4182 /(?(?=(a))a)(b)/
4183     ab
4184
4185 /^(?:a|ab)++c/
4186     aaaabc
4187
4188 /^(?>a|ab)++c/
4189     aaaabc
4190
4191 /^(?:a|ab)+c/
4192     aaaabc
4193
4194 /(?=abc){3}abc/+
4195     abcabcabc
4196     ** Failers
4197     xyz  
4198     
4199 /(?=abc)+abc/+
4200     abcabcabc
4201     ** Failers
4202     xyz  
4203     
4204 /(?=abc)++abc/+
4205     abcabcabc
4206     ** Failers
4207     xyz  
4208     
4209 /(?=abc){0}xyz/
4210     xyz 
4211
4212 /(?=abc){1}xyz/
4213     ** Failers
4214     xyz 
4215     
4216 /(?=(a))?./
4217     ab
4218     bc
4219       
4220 /(?=(a))??./
4221     ab
4222     bc
4223
4224 /^(?=(a)){0}b(?1)/
4225     backgammon
4226
4227 /^(?=(?1))?[az]([abc])d/
4228     abd 
4229     zcdxx 
4230
4231 /^(?!a){0}\w+/
4232     aaaaa
4233
4234 /(?<=(abc))?xyz/
4235     abcxyz
4236     pqrxyz 
4237
4238 /^[\g<a>]+/
4239     ggg<<<aaa>>>
4240     ** Failers
4241     \\ga  
4242     
4243 /^[\ga]+/
4244     gggagagaxyz 
4245     
4246 /^[:a[:digit:]]+/
4247     aaaa444:::Z 
4248
4249 /^[:a[:digit:]:b]+/
4250     aaaa444:::bbbZ 
4251
4252 /[:a]xxx[b:]/
4253      :xxx:
4254      
4255 /(?<=a{2})b/i
4256     xaabc
4257     ** Failers
4258     xabc  
4259
4260 /(?<!a{2})b/i
4261     xabc
4262     ** Failers
4263     xaabc  
4264
4265 /(?<=a\h)c/
4266     xa c
4267     
4268 /(?<=[^a]{2})b/
4269     axxbc
4270     aAAbc 
4271     ** Failers
4272     xaabc    
4273
4274 /(?<=[^a]{2})b/i
4275     axxbc  
4276     ** Failers
4277     aAAbc 
4278     xaabc    
4279
4280 /(?<=a\H)c/
4281     abc
4282
4283 /(?<=a\V)c/
4284     abc
4285     
4286 /(?<=a\v)c/
4287     a\nc
4288
4289 /(?(?=c)c|d)++Y/
4290     XcccddYX
4291
4292 /(?(?=c)c|d)*+Y/
4293     XcccddYX
4294
4295 /^(a{2,3}){2,}+a/
4296     aaaaaaa
4297     ** Failers
4298     aaaaaa
4299     aaaaaaaaa 
4300
4301 /^(a{2,3})++a/
4302     ** Failers
4303     aaaaaa
4304
4305 /^(a{2,3})*+a/
4306     ** Failers
4307     aaaaaa
4308
4309 /ab\Cde/
4310     abXde
4311     
4312 /(?<=ab\Cde)X/
4313     abZdeX
4314
4315 /a[\CD]b/
4316     aCb
4317     aDb 
4318
4319 /a[\C-X]b/
4320     aJb
4321
4322 /\H\h\V\v/
4323     X X\x0a
4324     X\x09X\x0b
4325     ** Failers
4326     \xa0 X\x0a   
4327     
4328 /\H*\h+\V?\v{3,4}/ 
4329     \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
4330     \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
4331     \x09\x20\xa0\x0a\x0b\x0c
4332     ** Failers 
4333     \x09\x20\xa0\x0a\x0b
4334      
4335 /\H{3,4}/
4336     XY  ABCDE
4337     XY  PQR ST 
4338     
4339 /.\h{3,4}./
4340     XY  AB    PQRS
4341
4342 /\h*X\h?\H+Y\H?Z/
4343     >XNNNYZ
4344     >  X NYQZ
4345     ** Failers
4346     >XYZ   
4347     >  X NY Z
4348
4349 /\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
4350     >XY\x0aZ\x0aA\x0bNN\x0c
4351     >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
4352
4353 /(foo)\Kbar/
4354     foobar
4355    
4356 /(foo)(\Kbar|baz)/
4357     foobar
4358     foobaz 
4359
4360 /(foo\Kbar)baz/
4361     foobarbaz
4362
4363 /abc\K|def\K/g+
4364     Xabcdefghi
4365
4366 /ab\Kc|de\Kf/g+
4367     Xabcdefghi
4368     
4369 /(?=C)/g+
4370     ABCDECBA
4371     
4372 /^abc\K/+
4373     abcdef
4374     ** Failers
4375     defabcxyz   
4376
4377 /^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-02}Z/
4378     ababababbbabZXXXX
4379
4380 /(?<A>tom|bon)-\g{A}/
4381     tom-tom
4382     bon-bon 
4383     
4384 /(^(a|b\g{-1}))/
4385     bacxxx
4386
4387 /(?|(abc)|(xyz))\1/
4388     abcabc
4389     xyzxyz 
4390     ** Failers
4391     abcxyz
4392     xyzabc   
4393     
4394 /(?|(abc)|(xyz))(?1)/
4395     abcabc
4396     xyzabc 
4397     ** Failers 
4398     xyzxyz 
4399  
4400 /^X(?5)(a)(?|(b)|(q))(c)(d)(Y)/
4401     XYabcdY
4402
4403 /^X(?7)(a)(?|(b|(r)(s))|(q))(c)(d)(Y)/
4404     XYabcdY
4405
4406 /^X(?7)(a)(?|(b|(?|(r)|(t))(s))|(q))(c)(d)(Y)/
4407     XYabcdY
4408
4409 /(?'abc'\w+):\k<abc>{2}/
4410     a:aaxyz
4411     ab:ababxyz
4412     ** Failers
4413     a:axyz
4414     ab:abxyz
4415
4416 /(?'abc'\w+):\g{abc}{2}/
4417     a:aaxyz
4418     ab:ababxyz
4419     ** Failers
4420     a:axyz
4421     ab:abxyz
4422
4423 /^(?<ab>a)? (?(<ab>)b|c) (?('ab')d|e)/x
4424     abd
4425     ce
4426
4427 /^(a.)\g-1Z/
4428     aXaXZ
4429
4430 /^(a.)\g{-1}Z/
4431     aXaXZ
4432
4433 /^(?(DEFINE) (?<A> a) (?<B> b) )  (?&A) (?&B) /x
4434     abcd
4435
4436 /(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT))
4437   (?(DEFINE)
4438   (?<NAME_PAT>[a-z]+)
4439   (?<ADDRESS_PAT>\d+)
4440   )/x
4441     metcalfe 33
4442
4443 /(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))\b(?&byte)(\.(?&byte)){3}/
4444     1.2.3.4
4445     131.111.10.206
4446     10.0.0.0
4447     ** Failers
4448     10.6
4449     455.3.4.5
4450
4451 /\b(?&byte)(\.(?&byte)){3}(?(DEFINE)(?<byte>2[0-4]\d|25[0-5]|1\d\d|[1-9]?\d))/
4452     1.2.3.4
4453     131.111.10.206
4454     10.0.0.0
4455     ** Failers
4456     10.6
4457     455.3.4.5
4458
4459 /^(\w++|\s++)*$/
4460     now is the time for all good men to come to the aid of the party
4461     *** Failers
4462     this is not a line with only words and spaces!
4463
4464 /(\d++)(\w)/
4465     12345a
4466     *** Failers
4467     12345+
4468
4469 /a++b/
4470     aaab
4471
4472 /(a++b)/
4473     aaab
4474
4475 /(a++)b/
4476     aaab
4477
4478 /([^()]++|\([^()]*\))+/
4479     ((abc(ade)ufh()()x
4480
4481 /\(([^()]++|\([^()]+\))+\)/
4482     (abc)
4483     (abc(def)xyz)
4484     *** Failers
4485     ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
4486
4487 /^([^()]|\((?1)*\))*$/
4488     abc
4489     a(b)c
4490     a(b(c))d
4491     *** Failers)
4492     a(b(c)d
4493
4494 /^>abc>([^()]|\((?1)*\))*<xyz<$/
4495    >abc>123<xyz<
4496    >abc>1(2)3<xyz<
4497    >abc>(1(2)3)<xyz<
4498
4499 /^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/i
4500     1221
4501     Satanoscillatemymetallicsonatas
4502     AmanaplanacanalPanama
4503     AblewasIereIsawElba
4504     *** Failers
4505     Thequickbrownfox
4506
4507 /^(\d+|\((?1)([+*-])(?1)\)|-(?1))$/
4508     12
4509     (((2+2)*-3)-7)
4510     -12
4511     *** Failers
4512     ((2+2)*-3)-7)
4513
4514 /^(x(y|(?1){2})z)/
4515     xyz
4516     xxyzxyzz
4517     *** Failers
4518     xxyzz
4519     xxyzxyzxyzz
4520
4521 /((< (?: (?(R) \d++  | [^<>]*+) | (?2)) * >))/x
4522     <>
4523     <abcd>
4524     <abc <123> hij>
4525     <abc <def> hij>
4526     <abc<>def>
4527     <abc<>
4528     *** Failers
4529     <abc
4530
4531 /^a+(*FAIL)/
4532     aaaaaa
4533     
4534 /a+b?c+(*FAIL)/
4535     aaabccc
4536
4537 /a+b?(*PRUNE)c+(*FAIL)/
4538     aaabccc
4539
4540 /a+b?(*COMMIT)c+(*FAIL)/
4541     aaabccc
4542     
4543 /a+b?(*SKIP)c+(*FAIL)/
4544     aaabcccaaabccc
4545
4546 /^(?:aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
4547     aaaxxxxxx
4548     aaa++++++ 
4549     bbbxxxxx
4550     bbb+++++ 
4551     cccxxxx
4552     ccc++++ 
4553     dddddddd   
4554
4555 /^(aaa(*THEN)\w{6}|bbb(*THEN)\w{5}|ccc(*THEN)\w{4}|\w{3})/
4556     aaaxxxxxx
4557     aaa++++++ 
4558     bbbxxxxx
4559     bbb+++++ 
4560     cccxxxx
4561     ccc++++ 
4562     dddddddd   
4563
4564 /a+b?(*THEN)c+(*FAIL)/
4565     aaabccc
4566
4567 /(A (A|B(*ACCEPT)|C) D)(E)/x
4568     AB
4569     ABX
4570     AADE
4571     ACDE
4572     ** Failers
4573     AD 
4574         
4575 /^\W*+(?:((.)\W*+(?1)\W*+\2|)|((.)\W*+(?3)\W*+\4|\W*+.\W*+))\W*+$/i
4576     1221
4577     Satan, oscillate my metallic sonatas!
4578     A man, a plan, a canal: Panama!
4579     Able was I ere I saw Elba.
4580     *** Failers
4581     The quick brown fox
4582
4583 /^((.)(?1)\2|.)$/
4584     a
4585     aba
4586     aabaa  
4587     abcdcba 
4588     pqaabaaqp  
4589     ablewasiereisawelba
4590     rhubarb
4591     the quick brown fox  
4592
4593 /(a)(?<=b(?1))/
4594     baz
4595     ** Failers
4596     caz  
4597     
4598 /(?<=b(?1))(a)/
4599     zbaaz
4600     ** Failers
4601     aaa  
4602     
4603 /(?<X>a)(?<=b(?&X))/
4604     baz
4605
4606 /^(?|(abc)|(def))\1/
4607     abcabc
4608     defdef 
4609     ** Failers
4610     abcdef
4611     defabc   
4612     
4613 /^(?|(abc)|(def))(?1)/
4614     abcabc
4615     defabc
4616     ** Failers
4617     defdef
4618     abcdef    
4619
4620 /(?:a(?<quote> (?<apostrophe>')|(?<realquote>")) |b(?<quote> (?<apostrophe>')|(?<realquote>")) ) (?('quote')[a-z]+|[0-9]+)/xJ
4621     a\"aaaaa
4622     b\"aaaaa 
4623     ** Failers 
4624     b\"11111
4625
4626 /(?:(?1)|B)(A(*F)|C)/
4627     ABCD
4628     CCD
4629     ** Failers
4630     CAD   
4631
4632 /^(?:(?1)|B)(A(*F)|C)/
4633     CCD
4634     BCD 
4635     ** Failers
4636     ABCD
4637     CAD
4638     BAD    
4639
4640 /(?:(?1)|B)(A(*ACCEPT)XX|C)D/
4641     AAD
4642     ACD
4643     BAD
4644     BCD
4645     BAX  
4646     ** Failers
4647     ACX
4648     ABC   
4649
4650 /(?(DEFINE)(A))B(?1)C/
4651     BAC
4652
4653 /(?(DEFINE)((A)\2))B(?1)C/
4654     BAAC
4655
4656 /(?<pn> \( ( [^()]++ | (?&pn) )* \) )/x
4657     (ab(cd)ef)
4658
4659 /^(?!a(*SKIP)b)/
4660     ac
4661     
4662 /^(?=a(*SKIP)b|ac)/
4663     ** Failers
4664     ac
4665     
4666 /^(?=a(*THEN)b|ac)/
4667     ac
4668     
4669 /^(?=a(*PRUNE)b)/
4670     ab  
4671     ** Failers 
4672     ac
4673
4674 /^(?=a(*ACCEPT)b)/
4675     ac
4676
4677 /^(?(?!a(*SKIP)b))/
4678     ac
4679
4680 /(?>a\Kb)/
4681     ab
4682
4683 /((?>a\Kb))/
4684     ab
4685
4686 /(a\Kb)/
4687     ab
4688     
4689 /^a\Kcz|ac/
4690     ac
4691     
4692 /(?>a\Kbz|ab)/
4693     ab 
4694
4695 /^(?&t)(?(DEFINE)(?<t>a\Kb))$/
4696     ab
4697
4698 /^([^()]|\((?1)*\))*$/
4699     a(b)c
4700     a(b(c)d)e 
4701
4702 /(?P<L1>(?P<L2>0)(?P>L1)|(?P>L2))/
4703     0
4704     00
4705     0000  
4706
4707 /(?P<L1>(?P<L2>0)|(?P>L2)(?P>L1))/
4708     0
4709     00
4710     0000  
4711
4712 /--- This one does fail, as expected, in Perl. It needs the complex item at the
4713      end of the pattern. A single letter instead of (B|D) makes it not fail,
4714      which I think is a Perl bug. --- /
4715
4716 /A(*COMMIT)(B|D)/
4717     ACABX
4718
4719 /--- Check the use of names for failure ---/
4720
4721 /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/K
4722     ** Failers
4723     AC
4724     CB    
4725     
4726 /--- Force no study, otherwise mark is not seen. The studied version is in
4727      test 2 because it isn't Perl-compatible. ---/
4728
4729 /(*MARK:A)(*SKIP:B)(C|X)/KSS
4730     C
4731     D
4732      
4733 /^(A(*THEN:A)B|C(*THEN:B)D)/K
4734     ** Failers
4735     CB    
4736
4737 /^(?:A(*THEN:A)B|C(*THEN:B)D)/K
4738     CB    
4739     
4740 /^(?>A(*THEN:A)B|C(*THEN:B)D)/K
4741     CB    
4742     
4743 /--- This should succeed, as the skip causes bump to offset 1 (the mark). Note
4744 that we have to have something complicated such as (B|Z) at the end because,
4745 for Perl, a simple character somehow causes an unwanted optimization to mess
4746 with the handling of backtracking verbs. ---/
4747
4748 /A(*MARK:A)A+(*SKIP:A)(B|Z) | AC/xK
4749     AAAC
4750     
4751 /--- Test skipping over a non-matching mark. ---/
4752
4753 /A(*MARK:A)A+(*MARK:B)(*SKIP:A)(B|Z) | AC/xK
4754     AAAC
4755     
4756 /--- Check shorthand for MARK ---/
4757
4758 /A(*:A)A+(*SKIP:A)(B|Z) | AC/xK
4759     AAAC
4760
4761 /--- Don't loop! Force no study, otherwise mark is not seen. ---/
4762
4763 /(*:A)A+(*SKIP:A)(B|Z)/KSS
4764     AAAC
4765
4766 /--- This should succeed, as a non-existent skip name disables the skip ---/ 
4767
4768 /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC/xK
4769     AAAC
4770
4771 /A(*MARK:A)A+(*SKIP:B)(B|Z) | AC(*:B)/xK
4772     AAAC
4773
4774 /--- COMMIT at the start of a pattern should act like an anchor. Again, 
4775 however, we need the complication for Perl. ---/
4776
4777 /(*COMMIT)(A|P)(B|P)(C|P)/
4778     ABCDEFG
4779     ** Failers
4780     DEFGABC  
4781
4782 /--- COMMIT inside an atomic group can't stop backtracking over the group. ---/
4783
4784 /(\w+)(?>b(*COMMIT))\w{2}/
4785     abbb
4786
4787 /(\w+)b(*COMMIT)\w{2}/
4788     abbb
4789
4790 /--- Check opening parens in comment when seeking forward reference. ---/ 
4791
4792 /(?&t)(?#()(?(DEFINE)(?<t>a))/
4793     bac
4794
4795 /--- COMMIT should override THEN ---/
4796
4797 /(?>(*COMMIT)(?>yes|no)(*THEN)(*F))?/
4798   yes
4799
4800 /(?>(*COMMIT)(yes|no)(*THEN)(*F))?/
4801   yes
4802
4803 /b?(*SKIP)c/
4804     bc
4805     abc
4806    
4807 /(*SKIP)bc/
4808     a
4809
4810 /(*SKIP)b/
4811     a 
4812
4813 /(?P<abn>(?P=abn)xxx|)+/
4814     xxx
4815
4816 /(?i:([^b]))(?1)/
4817     aa
4818     aA     
4819     ** Failers
4820     ab
4821     aB
4822     Ba
4823     ba
4824
4825 /^(?&t)*+(?(DEFINE)(?<t>a))\w$/
4826     aaaaaaX
4827     ** Failers 
4828     aaaaaa 
4829
4830 /^(?&t)*(?(DEFINE)(?<t>a))\w$/
4831     aaaaaaX
4832     aaaaaa 
4833
4834 /^(a)*+(\w)/
4835     aaaaX
4836     YZ 
4837     ** Failers 
4838     aaaa
4839
4840 /^(?:a)*+(\w)/
4841     aaaaX
4842     YZ 
4843     ** Failers 
4844     aaaa
4845
4846 /^(a)++(\w)/
4847     aaaaX
4848     ** Failers 
4849     aaaa
4850     YZ 
4851
4852 /^(?:a)++(\w)/
4853     aaaaX
4854     ** Failers 
4855     aaaa
4856     YZ 
4857
4858 /^(a)?+(\w)/
4859     aaaaX
4860     YZ 
4861
4862 /^(?:a)?+(\w)/
4863     aaaaX
4864     YZ 
4865
4866 /^(a){2,}+(\w)/
4867     aaaaX
4868     ** Failers
4869     aaa
4870     YZ 
4871
4872 /^(?:a){2,}+(\w)/
4873     aaaaX
4874     ** Failers
4875     aaa
4876     YZ 
4877
4878 /(a|)*(?1)b/
4879     b
4880     ab
4881     aab  
4882
4883 /(a)++(?1)b/
4884     ** Failers
4885     ab 
4886     aab
4887
4888 /(a)*+(?1)b/
4889     ** Failers
4890     ab
4891     aab  
4892
4893 /(?1)(?:(b)){0}/
4894     b
4895
4896 /(foo ( \( ((?:(?> [^()]+ )|(?2))*) \) ) )/x
4897     foo(bar(baz)+baz(bop))
4898
4899 /(A (A|B(*ACCEPT)|C) D)(E)/x
4900     AB
4901
4902 /\A.*?(?:a|b(*THEN)c)/
4903     ba
4904
4905 /\A.*?(?:a|bc)/
4906     ba
4907
4908 /\A.*?(a|b(*THEN)c)/
4909     ba
4910
4911 /\A.*?(a|bc)/
4912     ba
4913
4914 /\A.*?(?:a|b(*THEN)c)++/
4915     ba
4916
4917 /\A.*?(?:a|bc)++/
4918     ba
4919
4920 /\A.*?(a|b(*THEN)c)++/
4921     ba
4922
4923 /\A.*?(a|bc)++/
4924     ba
4925
4926 /\A.*?(?:a|b(*THEN)c|d)/
4927     ba
4928
4929 /\A.*?(?:a|bc|d)/
4930     ba
4931
4932 /(?:(b))++/
4933     beetle
4934
4935 /(?(?=(a(*ACCEPT)z))a)/
4936     a
4937
4938 /^(a)(?1)+ab/
4939     aaaab
4940     
4941 /^(a)(?1)++ab/
4942     aaaab
4943
4944 /^(?=a(*:M))aZ/K
4945     aZbc
4946
4947 /^(?!(*:M)b)aZ/K
4948     aZbc
4949
4950 /(?(DEFINE)(a))?b(?1)/
4951     backgammon
4952
4953 /^\N+/
4954     abc\ndef
4955     
4956 /^\N{1,}/
4957     abc\ndef 
4958
4959 /(?(R)a+|(?R)b)/
4960     aaaabcde
4961
4962 /(?(R)a+|((?R))b)/
4963     aaaabcde
4964
4965 /((?(R)a+|(?1)b))/
4966     aaaabcde
4967
4968 /((?(R1)a+|(?1)b))/
4969     aaaabcde
4970
4971 /a(*:any 
4972 name)/K
4973     abc
4974     
4975 /(?>(?&t)c|(?&t))(?(DEFINE)(?<t>a|b(*PRUNE)c))/
4976     a
4977     ba
4978     bba 
4979     
4980 /--- Checking revised (*THEN) handling ---/ 
4981
4982 /--- Capture ---/
4983
4984 /^.*? (a(*THEN)b) c/x
4985     aabc
4986
4987 /^.*? (a(*THEN)b|(*F)) c/x
4988     aabc
4989
4990 /^.*? ( (a(*THEN)b) | (*F) ) c/x
4991     aabc
4992
4993 /^.*? ( (a(*THEN)b) ) c/x
4994     aabc
4995
4996 /--- Non-capture ---/
4997
4998 /^.*? (?:a(*THEN)b) c/x
4999     aabc
5000
5001 /^.*? (?:a(*THEN)b|(*F)) c/x
5002     aabc
5003
5004 /^.*? (?: (?:a(*THEN)b) | (*F) ) c/x
5005     aabc
5006
5007 /^.*? (?: (?:a(*THEN)b) ) c/x
5008     aabc
5009
5010 /--- Atomic ---/
5011
5012 /^.*? (?>a(*THEN)b) c/x
5013     aabc
5014
5015 /^.*? (?>a(*THEN)b|(*F)) c/x
5016     aabc
5017
5018 /^.*? (?> (?>a(*THEN)b) | (*F) ) c/x
5019     aabc
5020
5021 /^.*? (?> (?>a(*THEN)b) ) c/x
5022     aabc
5023
5024 /--- Possessive capture ---/
5025
5026 /^.*? (a(*THEN)b)++ c/x
5027     aabc
5028
5029 /^.*? (a(*THEN)b|(*F))++ c/x
5030     aabc
5031
5032 /^.*? ( (a(*THEN)b)++ | (*F) )++ c/x
5033     aabc
5034
5035 /^.*? ( (a(*THEN)b)++ )++ c/x
5036     aabc
5037
5038 /--- Possessive non-capture ---/
5039
5040 /^.*? (?:a(*THEN)b)++ c/x
5041     aabc
5042
5043 /^.*? (?:a(*THEN)b|(*F))++ c/x
5044     aabc
5045
5046 /^.*? (?: (?:a(*THEN)b)++ | (*F) )++ c/x
5047     aabc
5048
5049 /^.*? (?: (?:a(*THEN)b)++ )++ c/x
5050     aabc
5051     
5052 /--- Condition assertion ---/
5053
5054 /^(?(?=a(*THEN)b)ab|ac)/
5055     ac
5056  
5057 /--- Condition ---/
5058
5059 /^.*?(?(?=a)a|b(*THEN)c)/
5060     ba
5061
5062 /^.*?(?:(?(?=a)a|b(*THEN)c)|d)/
5063     ba
5064
5065 /^.*?(?(?=a)a(*THEN)b|c)/
5066     ac
5067
5068 /--- Assertion ---/
5069
5070 /^.*(?=a(*THEN)b)/ 
5071     aabc
5072
5073 /------------------------------/
5074
5075 /(?>a(*:m))/imsxSK 
5076     a
5077
5078 /(?>(a)(*:m))/imsxSK 
5079     a
5080
5081 /(?<=a(*ACCEPT)b)c/
5082     xacd
5083
5084 /(?<=(a(*ACCEPT)b))c/
5085     xacd
5086
5087 /(?<=(a(*COMMIT)b))c/
5088     xabcd
5089     ** Failers 
5090     xacd
5091     
5092 /(?<!a(*FAIL)b)c/
5093     xcd
5094     acd 
5095
5096 /(?<=a(*:N)b)c/K
5097     xabcd
5098     
5099 /(?<=a(*PRUNE)b)c/
5100     xabcd 
5101
5102 /(?<=a(*SKIP)b)c/
5103     xabcd 
5104
5105 /(?<=a(*THEN)b)c/
5106     xabcd 
5107
5108 /(a)(?2){2}(.)/
5109     abcd
5110
5111 /(*MARK:A)(*PRUNE:B)(C|X)/KS
5112     C
5113     D 
5114
5115 /(*MARK:A)(*PRUNE:B)(C|X)/KSS
5116     C
5117     D 
5118
5119 /(*MARK:A)(*THEN:B)(C|X)/KS
5120     C
5121     D 
5122
5123 /(*MARK:A)(*THEN:B)(C|X)/KSY
5124     C
5125     D 
5126
5127 /(*MARK:A)(*THEN:B)(C|X)/KSS
5128     C
5129     D 
5130
5131 /--- This should fail, as the skip causes a bump to offset 3 (the skip) ---/
5132
5133 /A(*MARK:A)A+(*SKIP)(B|Z) | AC/xK
5134     AAAC
5135
5136 /--- Same --/
5137
5138 /A(*MARK:A)A+(*MARK:B)(*SKIP:B)(B|Z) | AC/xK
5139     AAAC
5140
5141 /A(*:A)A+(*SKIP)(B|Z) | AC/xK
5142     AAAC
5143
5144 /--- This should fail, as a null name is the same as no name ---/
5145
5146 /A(*MARK:A)A+(*SKIP:)(B|Z) | AC/xK
5147     AAAC
5148
5149 /--- A check on what happens after hitting a mark and them bumping along to
5150 something that does not even start. Perl reports tags after the failures here, 
5151 though it does not when the individual letters are made into something 
5152 more complicated. ---/
5153
5154 /A(*:A)B|XX(*:B)Y/K
5155     AABC
5156     XXYZ 
5157     ** Failers
5158     XAQQ  
5159     XAQQXZZ  
5160     AXQQQ 
5161     AXXQQQ 
5162     
5163 /^(A(*THEN:A)B|C(*THEN:B)D)/K
5164     AB
5165     CD
5166     ** Failers
5167     AC
5168     CB    
5169     
5170 /^(A(*PRUNE:A)B|C(*PRUNE:B)D)/K
5171     AB
5172     CD
5173     ** Failers
5174     AC
5175     CB    
5176     
5177 /--- An empty name does not pass back an empty string. It is the same as if no
5178 name were given. ---/ 
5179
5180 /^(A(*PRUNE:)B|C(*PRUNE:B)D)/K
5181     AB
5182     CD 
5183
5184 /--- PRUNE goes to next bumpalong; COMMIT does not. ---/
5185     
5186 /A(*PRUNE:A)B/K
5187     ACAB
5188
5189 /--- Mark names can be duplicated ---/
5190
5191 /A(*:A)B|X(*:A)Y/K
5192     AABC
5193     XXYZ 
5194     
5195 /b(*:m)f|a(*:n)w/K
5196     aw 
5197     ** Failers 
5198     abc
5199
5200 /b(*:m)f|aw/K
5201     abaw
5202     ** Failers 
5203     abc
5204     abax 
5205
5206 /A(*MARK:A)A+(*SKIP:B)(B|Z) | AAC/xK
5207     AAAC
5208
5209 /a(*PRUNE:X)bc|qq/KY
5210     ** Failers
5211     axy
5212
5213 /a(*THEN:X)bc|qq/KY
5214     ** Failers
5215     axy
5216
5217 /(?=a(*MARK:A)b)..x/K
5218     abxy
5219     ** Failers
5220     abpq  
5221
5222 /(?=a(*MARK:A)b)..(*:Y)x/K
5223     abxy
5224     ** Failers
5225     abpq  
5226
5227 /(?=a(*PRUNE:A)b)..x/K
5228     abxy
5229     ** Failers
5230     abpq  
5231
5232 /(?=a(*PRUNE:A)b)..(*:Y)x/K
5233     abxy
5234     ** Failers
5235     abpq  
5236
5237 /(?=a(*THEN:A)b)..x/K
5238     abxy
5239     ** Failers
5240     abpq  
5241
5242 /(?=a(*THEN:A)b)..(*:Y)x/K
5243     abxy
5244     ** Failers
5245     abpq  
5246
5247 /(another)?(\1?)test/
5248     hello world test
5249
5250 /(another)?(\1+)test/
5251     hello world test
5252
5253 /-- End of testinput1 --/