chiark / gitweb /
Commit upstream pcre-8.39.tar.bz2
[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 the 8-bit, 16-bit,
3     and 32-bit PCRE libraries. --/
4     
5 < forbid 89?=ABCDEFfGILMNPTUWXZ<
6
7 /the quick brown fox/
8     the quick brown fox
9     The quick brown FOX
10     What do you know about the quick brown fox?
11     What do you know about THE QUICK BROWN FOX?
12
13 /The quick brown fox/i
14     the quick brown fox
15     The quick brown FOX
16     What do you know about the quick brown fox?
17     What do you know about THE QUICK BROWN FOX?
18
19 /abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
20     abcd\t\n\r\f\a\e9;\$\\?caxyz
21
22 /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
23     abxyzpqrrrabbxyyyypqAzz
24     abxyzpqrrrabbxyyyypqAzz
25     aabxyzpqrrrabbxyyyypqAzz
26     aaabxyzpqrrrabbxyyyypqAzz
27     aaaabxyzpqrrrabbxyyyypqAzz
28     abcxyzpqrrrabbxyyyypqAzz
29     aabcxyzpqrrrabbxyyyypqAzz
30     aaabcxyzpqrrrabbxyyyypAzz
31     aaabcxyzpqrrrabbxyyyypqAzz
32     aaabcxyzpqrrrabbxyyyypqqAzz
33     aaabcxyzpqrrrabbxyyyypqqqAzz
34     aaabcxyzpqrrrabbxyyyypqqqqAzz
35     aaabcxyzpqrrrabbxyyyypqqqqqAzz
36     aaabcxyzpqrrrabbxyyyypqqqqqqAzz
37     aaaabcxyzpqrrrabbxyyyypqAzz
38     abxyzzpqrrrabbxyyyypqAzz
39     aabxyzzzpqrrrabbxyyyypqAzz
40     aaabxyzzzzpqrrrabbxyyyypqAzz
41     aaaabxyzzzzpqrrrabbxyyyypqAzz
42     abcxyzzpqrrrabbxyyyypqAzz
43     aabcxyzzzpqrrrabbxyyyypqAzz
44     aaabcxyzzzzpqrrrabbxyyyypqAzz
45     aaaabcxyzzzzpqrrrabbxyyyypqAzz
46     aaaabcxyzzzzpqrrrabbbxyyyypqAzz
47     aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
48     aaabcxyzpqrrrabbxyyyypABzz
49     aaabcxyzpqrrrabbxyyyypABBzz
50     >>>aaabxyzpqrrrabbxyyyypqAzz
51     >aaaabxyzpqrrrabbxyyyypqAzz
52     >>>>abcxyzpqrrrabbxyyyypqAzz
53     *** Failers
54     abxyzpqrrabbxyyyypqAzz
55     abxyzpqrrrrabbxyyyypqAzz
56     abxyzpqrrrabxyyyypqAzz
57     aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
58     aaaabcxyzzzzpqrrrabbbxyyypqAzz
59     aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
60
61 /^(abc){1,2}zz/
62     abczz
63     abcabczz
64     *** Failers
65     zz
66     abcabcabczz
67     >>abczz
68
69 /^(b+?|a){1,2}?c/
70     bc
71     bbc
72     bbbc
73     bac
74     bbac
75     aac
76     abbbbbbbbbbbc
77     bbbbbbbbbbbac
78     *** Failers
79     aaac
80     abbbbbbbbbbbac
81
82 /^(b+|a){1,2}c/
83     bc
84     bbc
85     bbbc
86     bac
87     bbac
88     aac
89     abbbbbbbbbbbc
90     bbbbbbbbbbbac
91     *** Failers
92     aaac
93     abbbbbbbbbbbac
94
95 /^(b+|a){1,2}?bc/
96     bbc
97
98 /^(b*|ba){1,2}?bc/
99     babc
100     bbabc
101     bababc
102     *** Failers
103     bababbc
104     babababc
105
106 /^(ba|b*){1,2}?bc/
107     babc
108     bbabc
109     bababc
110     *** Failers
111     bababbc
112     babababc
113
114 /^\ca\cA\c[;\c:/
115     \x01\x01\e;z
116
117 /^[ab\]cde]/
118     athing
119     bthing
120     ]thing
121     cthing
122     dthing
123     ething
124     *** Failers
125     fthing
126     [thing
127     \\thing
128
129 /^[]cde]/
130     ]thing
131     cthing
132     dthing
133     ething
134     *** Failers
135     athing
136     fthing
137
138 /^[^ab\]cde]/
139     fthing
140     [thing
141     \\thing
142     *** Failers
143     athing
144     bthing
145     ]thing
146     cthing
147     dthing
148     ething
149
150 /^[^]cde]/
151     athing
152     fthing
153     *** Failers
154     ]thing
155     cthing
156     dthing
157     ething
158
159 /^\\81/
160     \81
161
162 /^ÿ/
163     ÿ
164
165 /^[0-9]+$/
166     0
167     1
168     2
169     3
170     4
171     5
172     6
173     7
174     8
175     9
176     10
177     100
178     *** Failers
179     abc
180
181 /^.*nter/
182     enter
183     inter
184     uponter
185
186 /^xxx[0-9]+$/
187     xxx0
188     xxx1234
189     *** Failers
190     xxx
191
192 /^.+[0-9][0-9][0-9]$/
193     x123
194     xx123
195     123456
196     *** Failers
197     123
198     x1234
199
200 /^.+?[0-9][0-9][0-9]$/
201     x123
202     xx123
203     123456
204     *** Failers
205     123
206     x1234
207
208 /^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
209     abc!pqr=apquxz.ixr.zzz.ac.uk
210     *** Failers
211     !pqr=apquxz.ixr.zzz.ac.uk
212     abc!=apquxz.ixr.zzz.ac.uk
213     abc!pqr=apquxz:ixr.zzz.ac.uk
214     abc!pqr=apquxz.ixr.zzz.ac.ukk
215
216 /:/
217     Well, we need a colon: somewhere
218     *** Fail if we don't
219
220 /([\da-f:]+)$/i
221     0abc
222     abc
223     fed
224     E
225     ::
226     5f03:12C0::932e
227     fed def
228     Any old stuff
229     *** Failers
230     0zzz
231     gzzz
232     fed\x20
233     Any old rubbish
234
235 /^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
236     .1.2.3
237     A.12.123.0
238     *** Failers
239     .1.2.3333
240     1.2.3
241     1234.2.3
242
243 /^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
244     1 IN SOA non-sp1 non-sp2(
245     1    IN    SOA    non-sp1    non-sp2   (
246     *** Failers
247     1IN SOA non-sp1 non-sp2(
248
249 /^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
250     a.
251     Z.
252     2.
253     ab-c.pq-r.
254     sxk.zzz.ac.uk.
255     x-.y-.
256     *** Failers
257     -abc.peq.
258
259 /^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
260     *.a
261     *.b0-a
262     *.c3-b.c
263     *.c-a.b-c
264     *** Failers
265     *.0
266     *.a-
267     *.a-b.c-
268     *.c-a.0-c
269
270 /^(?=ab(de))(abd)(e)/
271     abde
272
273 /^(?!(ab)de|x)(abd)(f)/
274     abdf
275
276 /^(?=(ab(cd)))(ab)/
277     abcd
278
279 /^[\da-f](\.[\da-f])*$/i
280     a.b.c.d
281     A.B.C.D
282     a.b.c.1.2.3.C
283
284 /^\".*\"\s*(;.*)?$/
285     \"1234\"
286     \"abcd\" ;
287     \"\" ; rhubarb
288     *** Failers
289     \"1234\" : things
290
291 /^$/
292     \
293     *** Failers
294
295 /   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/x
296     ab c
297     *** Failers
298     abc
299     ab cde
300
301 /(?x)   ^    a   (?# begins with a)  b\sc (?# then b c) $ (?# then end)/
302     ab c
303     *** Failers
304     abc
305     ab cde
306
307 /^   a\ b[c ]d       $/x
308     a bcd
309     a b d
310     *** Failers
311     abcd
312     ab d
313
314 /^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
315     abcdefhijklm
316
317 /^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
318     abcdefhijklm
319
320 /^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
321     a+ Z0+\x08\n\x1d\x12
322
323 /^[.^$|()*+?{,}]+/
324     .^\$(*+)|{?,?}
325
326 /^a*\w/
327     z
328     az
329     aaaz
330     a
331     aa
332     aaaa
333     a+
334     aa+
335
336 /^a*?\w/
337     z
338     az
339     aaaz
340     a
341     aa
342     aaaa
343     a+
344     aa+
345
346 /^a+\w/
347     az
348     aaaz
349     aa
350     aaaa
351     aa+
352
353 /^a+?\w/
354     az
355     aaaz
356     aa
357     aaaa
358     aa+
359
360 /^\d{8}\w{2,}/
361     1234567890
362     12345678ab
363     12345678__
364     *** Failers
365     1234567
366
367 /^[aeiou\d]{4,5}$/
368     uoie
369     1234
370     12345
371     aaaaa
372     *** Failers
373     123456
374
375 /^[aeiou\d]{4,5}?/
376     uoie
377     1234
378     12345
379     aaaaa
380     123456
381
382 /\A(abc|def)=(\1){2,3}\Z/
383     abc=abcabc
384     def=defdefdef
385     *** Failers
386     abc=defdef
387
388 /^(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\11*(\3\4)\1(?#)2$/
389     abcdefghijkcda2
390     abcdefghijkkkkcda2
391
392 /(cat(a(ract|tonic)|erpillar)) \1()2(3)/
393     cataract cataract23
394     catatonic catatonic23
395     caterpillar caterpillar23
396
397
398 /^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]/
399     From abcd  Mon Sep 01 12:33:02 1997
400
401 /^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
402     From abcd  Mon Sep 01 12:33:02 1997
403     From abcd  Mon Sep  1 12:33:02 1997
404     *** Failers
405     From abcd  Sep 01 12:33:02 1997
406
407 /^12.34/s
408     12\n34
409     12\r34
410
411 /\w+(?=\t)/
412     the quick brown\t fox
413
414 /foo(?!bar)(.*)/
415     foobar is foolish see?
416
417 /(?:(?!foo)...|^.{0,2})bar(.*)/
418     foobar crowbar etc
419     barrel
420     2barrel
421     A barrel
422
423 /^(\D*)(?=\d)(?!123)/
424     abc456
425     *** Failers
426     abc123
427
428 /^1234(?# test newlines
429   inside)/
430     1234
431
432 /^1234 #comment in extended re
433   /x
434     1234
435
436 /#rhubarb
437   abcd/x
438     abcd
439
440 /^abcd#rhubarb/x
441     abcd
442
443 /^(a)\1{2,3}(.)/
444     aaab
445     aaaab
446     aaaaab
447     aaaaaab
448
449 /(?!^)abc/
450     the abc
451     *** Failers
452     abc
453
454 /(?=^)abc/
455     abc
456     *** Failers
457     the abc
458
459 /^[ab]{1,3}(ab*|b)/
460     aabbbbb
461
462 /^[ab]{1,3}?(ab*|b)/
463     aabbbbb
464
465 /^[ab]{1,3}?(ab*?|b)/
466     aabbbbb
467
468 /^[ab]{1,3}(ab*?|b)/
469     aabbbbb
470
471 /  (?: [\040\t] |  \(
472 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
473 \)  )*                          # optional leading comment
474 (?:    (?:
475 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
476 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
477 |
478 " (?:                      # opening quote...
479 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
480 |                     #    or
481 \\ [^\x80-\xff]           #   Escaped something (something != CR)
482 )* "  # closing quote
483 )                    # initial word
484 (?:  (?: [\040\t] |  \(
485 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
486 \)  )*  \.  (?: [\040\t] |  \(
487 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
488 \)  )*   (?:
489 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
490 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
491 |
492 " (?:                      # opening quote...
493 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
494 |                     #    or
495 \\ [^\x80-\xff]           #   Escaped something (something != CR)
496 )* "  # closing quote
497 )  )* # further okay, if led by a period
498 (?: [\040\t] |  \(
499 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
500 \)  )*  @  (?: [\040\t] |  \(
501 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
502 \)  )*    (?:
503 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
504 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
505 |   \[                         # [
506 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
507 \]                        #           ]
508 )                           # initial subdomain
509 (?:                                  #
510 (?: [\040\t] |  \(
511 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
512 \)  )*  \.                        # if led by a period...
513 (?: [\040\t] |  \(
514 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
515 \)  )*   (?:
516 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
517 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
518 |   \[                         # [
519 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
520 \]                        #           ]
521 )                     #   ...further okay
522 )*
523 # address
524 |                     #  or
525 (?:
526 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
527 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
528 |
529 " (?:                      # opening quote...
530 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
531 |                     #    or
532 \\ [^\x80-\xff]           #   Escaped something (something != CR)
533 )* "  # closing quote
534 )             # one word, optionally followed by....
535 (?:
536 [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]  |  # atom and space parts, or...
537 \(
538 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
539 \)       |  # comments, or...
540
541 " (?:                      # opening quote...
542 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
543 |                     #    or
544 \\ [^\x80-\xff]           #   Escaped something (something != CR)
545 )* "  # closing quote
546 # quoted strings
547 )*
548 <  (?: [\040\t] |  \(
549 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
550 \)  )*                     # leading <
551 (?:  @  (?: [\040\t] |  \(
552 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
553 \)  )*    (?:
554 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
555 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
556 |   \[                         # [
557 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
558 \]                        #           ]
559 )                           # initial subdomain
560 (?:                                  #
561 (?: [\040\t] |  \(
562 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
563 \)  )*  \.                        # if led by a period...
564 (?: [\040\t] |  \(
565 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
566 \)  )*   (?:
567 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
568 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
569 |   \[                         # [
570 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
571 \]                        #           ]
572 )                     #   ...further okay
573 )*
574
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 \)  )*  @  (?: [\040\t] |  \(
580 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
581 \)  )*    (?:
582 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
583 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
584 |   \[                         # [
585 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
586 \]                        #           ]
587 )                           # initial subdomain
588 (?:                                  #
589 (?: [\040\t] |  \(
590 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
591 \)  )*  \.                        # if led by a period...
592 (?: [\040\t] |  \(
593 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
594 \)  )*   (?:
595 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
596 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
597 |   \[                         # [
598 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
599 \]                        #           ]
600 )                     #   ...further okay
601 )*
602 )* # further okay, if led by comma
603 :                                # closing colon
604 (?: [\040\t] |  \(
605 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
606 \)  )*  )? #       optional route
607 (?:
608 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
609 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
610 |
611 " (?:                      # opening quote...
612 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
613 |                     #    or
614 \\ [^\x80-\xff]           #   Escaped something (something != CR)
615 )* "  # closing quote
616 )                    # initial word
617 (?:  (?: [\040\t] |  \(
618 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
619 \)  )*  \.  (?: [\040\t] |  \(
620 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
621 \)  )*   (?:
622 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
623 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
624 |
625 " (?:                      # opening quote...
626 [^\\\x80-\xff\n\015"]                #   Anything except backslash and quote
627 |                     #    or
628 \\ [^\x80-\xff]           #   Escaped something (something != CR)
629 )* "  # closing quote
630 )  )* # further okay, if led by a period
631 (?: [\040\t] |  \(
632 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
633 \)  )*  @  (?: [\040\t] |  \(
634 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
635 \)  )*    (?:
636 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
637 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
638 |   \[                         # [
639 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
640 \]                        #           ]
641 )                           # initial subdomain
642 (?:                                  #
643 (?: [\040\t] |  \(
644 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
645 \)  )*  \.                        # if led by a period...
646 (?: [\040\t] |  \(
647 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
648 \)  )*   (?:
649 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
650 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
651 |   \[                         # [
652 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*    #    stuff
653 \]                        #           ]
654 )                     #   ...further okay
655 )*
656 #       address spec
657 (?: [\040\t] |  \(
658 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
659 \)  )*  > #                  trailing >
660 # name and address
661 )  (?: [\040\t] |  \(
662 (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  |  \( (?:  [^\\\x80-\xff\n\015()]  |  \\ [^\x80-\xff]  )* \)  )*
663 \)  )*                       # optional trailing comment
664 /x
665     Alan Other <user\@dom.ain>
666     <user\@dom.ain>
667     user\@dom.ain
668     \"A. Other\" <user.1234\@dom.ain> (a comment)
669     A. Other <user.1234\@dom.ain> (a comment)
670     \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
671     A missing angle <user\@some.where
672     *** Failers
673     The quick brown fox
674
675 /[\040\t]*                    # Nab whitespace.
676 (?:
677 \(                              #  (
678 [^\\\x80-\xff\n\015()] *                             #     normal*
679 (?:                                 #       (
680 (?:  \\ [^\x80-\xff]  |
681 \(                            #  (
682 [^\\\x80-\xff\n\015()] *                            #     normal*
683 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
684 \)                           #                       )
685 )    #         special
686 [^\\\x80-\xff\n\015()] *                         #         normal*
687 )*                                  #            )*
688 \)                             #                )
689 [\040\t]* )*    # If comment found, allow more spaces.
690 # optional leading comment
691 (?:
692 (?:
693 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
694 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
695 # Atom
696 |                       #  or
697 "                                     # "
698 [^\\\x80-\xff\n\015"] *                            #   normal
699 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
700 "                                     #        "
701 # Quoted string
702 )
703 [\040\t]*                    # Nab whitespace.
704 (?:
705 \(                              #  (
706 [^\\\x80-\xff\n\015()] *                             #     normal*
707 (?:                                 #       (
708 (?:  \\ [^\x80-\xff]  |
709 \(                            #  (
710 [^\\\x80-\xff\n\015()] *                            #     normal*
711 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
712 \)                           #                       )
713 )    #         special
714 [^\\\x80-\xff\n\015()] *                         #         normal*
715 )*                                  #            )*
716 \)                             #                )
717 [\040\t]* )*    # If comment found, allow more spaces.
718 (?:
719 \.
720 [\040\t]*                    # Nab whitespace.
721 (?:
722 \(                              #  (
723 [^\\\x80-\xff\n\015()] *                             #     normal*
724 (?:                                 #       (
725 (?:  \\ [^\x80-\xff]  |
726 \(                            #  (
727 [^\\\x80-\xff\n\015()] *                            #     normal*
728 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
729 \)                           #                       )
730 )    #         special
731 [^\\\x80-\xff\n\015()] *                         #         normal*
732 )*                                  #            )*
733 \)                             #                )
734 [\040\t]* )*    # If comment found, allow more spaces.
735 (?:
736 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
737 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
738 # Atom
739 |                       #  or
740 "                                     # "
741 [^\\\x80-\xff\n\015"] *                            #   normal
742 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
743 "                                     #        "
744 # Quoted string
745 )
746 [\040\t]*                    # Nab whitespace.
747 (?:
748 \(                              #  (
749 [^\\\x80-\xff\n\015()] *                             #     normal*
750 (?:                                 #       (
751 (?:  \\ [^\x80-\xff]  |
752 \(                            #  (
753 [^\\\x80-\xff\n\015()] *                            #     normal*
754 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
755 \)                           #                       )
756 )    #         special
757 [^\\\x80-\xff\n\015()] *                         #         normal*
758 )*                                  #            )*
759 \)                             #                )
760 [\040\t]* )*    # If comment found, allow more spaces.
761 # additional words
762 )*
763 @
764 [\040\t]*                    # Nab whitespace.
765 (?:
766 \(                              #  (
767 [^\\\x80-\xff\n\015()] *                             #     normal*
768 (?:                                 #       (
769 (?:  \\ [^\x80-\xff]  |
770 \(                            #  (
771 [^\\\x80-\xff\n\015()] *                            #     normal*
772 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
773 \)                           #                       )
774 )    #         special
775 [^\\\x80-\xff\n\015()] *                         #         normal*
776 )*                                  #            )*
777 \)                             #                )
778 [\040\t]* )*    # If comment found, allow more spaces.
779 (?:
780 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
781 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
782 |
783 \[                            # [
784 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
785 \]                           #           ]
786 )
787 [\040\t]*                    # Nab whitespace.
788 (?:
789 \(                              #  (
790 [^\\\x80-\xff\n\015()] *                             #     normal*
791 (?:                                 #       (
792 (?:  \\ [^\x80-\xff]  |
793 \(                            #  (
794 [^\\\x80-\xff\n\015()] *                            #     normal*
795 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
796 \)                           #                       )
797 )    #         special
798 [^\\\x80-\xff\n\015()] *                         #         normal*
799 )*                                  #            )*
800 \)                             #                )
801 [\040\t]* )*    # If comment found, allow more spaces.
802 # optional trailing comments
803 (?:
804 \.
805 [\040\t]*                    # Nab whitespace.
806 (?:
807 \(                              #  (
808 [^\\\x80-\xff\n\015()] *                             #     normal*
809 (?:                                 #       (
810 (?:  \\ [^\x80-\xff]  |
811 \(                            #  (
812 [^\\\x80-\xff\n\015()] *                            #     normal*
813 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
814 \)                           #                       )
815 )    #         special
816 [^\\\x80-\xff\n\015()] *                         #         normal*
817 )*                                  #            )*
818 \)                             #                )
819 [\040\t]* )*    # If comment found, allow more spaces.
820 (?:
821 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
822 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
823 |
824 \[                            # [
825 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
826 \]                           #           ]
827 )
828 [\040\t]*                    # Nab whitespace.
829 (?:
830 \(                              #  (
831 [^\\\x80-\xff\n\015()] *                             #     normal*
832 (?:                                 #       (
833 (?:  \\ [^\x80-\xff]  |
834 \(                            #  (
835 [^\\\x80-\xff\n\015()] *                            #     normal*
836 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
837 \)                           #                       )
838 )    #         special
839 [^\\\x80-\xff\n\015()] *                         #         normal*
840 )*                                  #            )*
841 \)                             #                )
842 [\040\t]* )*    # If comment found, allow more spaces.
843 # optional trailing comments
844 )*
845 # address
846 |                             #  or
847 (?:
848 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
849 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
850 # Atom
851 |                       #  or
852 "                                     # "
853 [^\\\x80-\xff\n\015"] *                            #   normal
854 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
855 "                                     #        "
856 # Quoted string
857 )
858 # leading word
859 [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *               # "normal" atoms and or spaces
860 (?:
861 (?:
862 \(                              #  (
863 [^\\\x80-\xff\n\015()] *                             #     normal*
864 (?:                                 #       (
865 (?:  \\ [^\x80-\xff]  |
866 \(                            #  (
867 [^\\\x80-\xff\n\015()] *                            #     normal*
868 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
869 \)                           #                       )
870 )    #         special
871 [^\\\x80-\xff\n\015()] *                         #         normal*
872 )*                                  #            )*
873 \)                             #                )
874 |
875 "                                     # "
876 [^\\\x80-\xff\n\015"] *                            #   normal
877 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
878 "                                     #        "
879 ) # "special" comment or quoted string
880 [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] *            #  more "normal"
881 )*
882 <
883 [\040\t]*                    # Nab whitespace.
884 (?:
885 \(                              #  (
886 [^\\\x80-\xff\n\015()] *                             #     normal*
887 (?:                                 #       (
888 (?:  \\ [^\x80-\xff]  |
889 \(                            #  (
890 [^\\\x80-\xff\n\015()] *                            #     normal*
891 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
892 \)                           #                       )
893 )    #         special
894 [^\\\x80-\xff\n\015()] *                         #         normal*
895 )*                                  #            )*
896 \)                             #                )
897 [\040\t]* )*    # If comment found, allow more spaces.
898 # <
899 (?:
900 @
901 [\040\t]*                    # Nab whitespace.
902 (?:
903 \(                              #  (
904 [^\\\x80-\xff\n\015()] *                             #     normal*
905 (?:                                 #       (
906 (?:  \\ [^\x80-\xff]  |
907 \(                            #  (
908 [^\\\x80-\xff\n\015()] *                            #     normal*
909 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
910 \)                           #                       )
911 )    #         special
912 [^\\\x80-\xff\n\015()] *                         #         normal*
913 )*                                  #            )*
914 \)                             #                )
915 [\040\t]* )*    # If comment found, allow more spaces.
916 (?:
917 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
918 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
919 |
920 \[                            # [
921 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
922 \]                           #           ]
923 )
924 [\040\t]*                    # Nab whitespace.
925 (?:
926 \(                              #  (
927 [^\\\x80-\xff\n\015()] *                             #     normal*
928 (?:                                 #       (
929 (?:  \\ [^\x80-\xff]  |
930 \(                            #  (
931 [^\\\x80-\xff\n\015()] *                            #     normal*
932 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
933 \)                           #                       )
934 )    #         special
935 [^\\\x80-\xff\n\015()] *                         #         normal*
936 )*                                  #            )*
937 \)                             #                )
938 [\040\t]* )*    # If comment found, allow more spaces.
939 # optional trailing comments
940 (?:
941 \.
942 [\040\t]*                    # Nab whitespace.
943 (?:
944 \(                              #  (
945 [^\\\x80-\xff\n\015()] *                             #     normal*
946 (?:                                 #       (
947 (?:  \\ [^\x80-\xff]  |
948 \(                            #  (
949 [^\\\x80-\xff\n\015()] *                            #     normal*
950 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
951 \)                           #                       )
952 )    #         special
953 [^\\\x80-\xff\n\015()] *                         #         normal*
954 )*                                  #            )*
955 \)                             #                )
956 [\040\t]* )*    # If comment found, allow more spaces.
957 (?:
958 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
959 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
960 |
961 \[                            # [
962 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
963 \]                           #           ]
964 )
965 [\040\t]*                    # Nab whitespace.
966 (?:
967 \(                              #  (
968 [^\\\x80-\xff\n\015()] *                             #     normal*
969 (?:                                 #       (
970 (?:  \\ [^\x80-\xff]  |
971 \(                            #  (
972 [^\\\x80-\xff\n\015()] *                            #     normal*
973 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
974 \)                           #                       )
975 )    #         special
976 [^\\\x80-\xff\n\015()] *                         #         normal*
977 )*                                  #            )*
978 \)                             #                )
979 [\040\t]* )*    # If comment found, allow more spaces.
980 # optional trailing comments
981 )*
982 (?: ,
983 [\040\t]*                    # Nab whitespace.
984 (?:
985 \(                              #  (
986 [^\\\x80-\xff\n\015()] *                             #     normal*
987 (?:                                 #       (
988 (?:  \\ [^\x80-\xff]  |
989 \(                            #  (
990 [^\\\x80-\xff\n\015()] *                            #     normal*
991 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
992 \)                           #                       )
993 )    #         special
994 [^\\\x80-\xff\n\015()] *                         #         normal*
995 )*                                  #            )*
996 \)                             #                )
997 [\040\t]* )*    # If comment found, allow more spaces.
998 @
999 [\040\t]*                    # Nab whitespace.
1000 (?:
1001 \(                              #  (
1002 [^\\\x80-\xff\n\015()] *                             #     normal*
1003 (?:                                 #       (
1004 (?:  \\ [^\x80-\xff]  |
1005 \(                            #  (
1006 [^\\\x80-\xff\n\015()] *                            #     normal*
1007 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1008 \)                           #                       )
1009 )    #         special
1010 [^\\\x80-\xff\n\015()] *                         #         normal*
1011 )*                                  #            )*
1012 \)                             #                )
1013 [\040\t]* )*    # If comment found, allow more spaces.
1014 (?:
1015 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1016 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1017 |
1018 \[                            # [
1019 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1020 \]                           #           ]
1021 )
1022 [\040\t]*                    # Nab whitespace.
1023 (?:
1024 \(                              #  (
1025 [^\\\x80-\xff\n\015()] *                             #     normal*
1026 (?:                                 #       (
1027 (?:  \\ [^\x80-\xff]  |
1028 \(                            #  (
1029 [^\\\x80-\xff\n\015()] *                            #     normal*
1030 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1031 \)                           #                       )
1032 )    #         special
1033 [^\\\x80-\xff\n\015()] *                         #         normal*
1034 )*                                  #            )*
1035 \)                             #                )
1036 [\040\t]* )*    # If comment found, allow more spaces.
1037 # optional trailing comments
1038 (?:
1039 \.
1040 [\040\t]*                    # Nab whitespace.
1041 (?:
1042 \(                              #  (
1043 [^\\\x80-\xff\n\015()] *                             #     normal*
1044 (?:                                 #       (
1045 (?:  \\ [^\x80-\xff]  |
1046 \(                            #  (
1047 [^\\\x80-\xff\n\015()] *                            #     normal*
1048 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1049 \)                           #                       )
1050 )    #         special
1051 [^\\\x80-\xff\n\015()] *                         #         normal*
1052 )*                                  #            )*
1053 \)                             #                )
1054 [\040\t]* )*    # If comment found, allow more spaces.
1055 (?:
1056 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1057 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1058 |
1059 \[                            # [
1060 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1061 \]                           #           ]
1062 )
1063 [\040\t]*                    # Nab whitespace.
1064 (?:
1065 \(                              #  (
1066 [^\\\x80-\xff\n\015()] *                             #     normal*
1067 (?:                                 #       (
1068 (?:  \\ [^\x80-\xff]  |
1069 \(                            #  (
1070 [^\\\x80-\xff\n\015()] *                            #     normal*
1071 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1072 \)                           #                       )
1073 )    #         special
1074 [^\\\x80-\xff\n\015()] *                         #         normal*
1075 )*                                  #            )*
1076 \)                             #                )
1077 [\040\t]* )*    # If comment found, allow more spaces.
1078 # optional trailing comments
1079 )*
1080 )*  # additional domains
1081 :
1082 [\040\t]*                    # Nab whitespace.
1083 (?:
1084 \(                              #  (
1085 [^\\\x80-\xff\n\015()] *                             #     normal*
1086 (?:                                 #       (
1087 (?:  \\ [^\x80-\xff]  |
1088 \(                            #  (
1089 [^\\\x80-\xff\n\015()] *                            #     normal*
1090 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1091 \)                           #                       )
1092 )    #         special
1093 [^\\\x80-\xff\n\015()] *                         #         normal*
1094 )*                                  #            )*
1095 \)                             #                )
1096 [\040\t]* )*    # If comment found, allow more spaces.
1097 # optional trailing comments
1098 )?     #       optional route
1099 (?:
1100 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1101 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1102 # Atom
1103 |                       #  or
1104 "                                     # "
1105 [^\\\x80-\xff\n\015"] *                            #   normal
1106 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1107 "                                     #        "
1108 # Quoted string
1109 )
1110 [\040\t]*                    # Nab whitespace.
1111 (?:
1112 \(                              #  (
1113 [^\\\x80-\xff\n\015()] *                             #     normal*
1114 (?:                                 #       (
1115 (?:  \\ [^\x80-\xff]  |
1116 \(                            #  (
1117 [^\\\x80-\xff\n\015()] *                            #     normal*
1118 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1119 \)                           #                       )
1120 )    #         special
1121 [^\\\x80-\xff\n\015()] *                         #         normal*
1122 )*                                  #            )*
1123 \)                             #                )
1124 [\040\t]* )*    # If comment found, allow more spaces.
1125 (?:
1126 \.
1127 [\040\t]*                    # Nab whitespace.
1128 (?:
1129 \(                              #  (
1130 [^\\\x80-\xff\n\015()] *                             #     normal*
1131 (?:                                 #       (
1132 (?:  \\ [^\x80-\xff]  |
1133 \(                            #  (
1134 [^\\\x80-\xff\n\015()] *                            #     normal*
1135 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1136 \)                           #                       )
1137 )    #         special
1138 [^\\\x80-\xff\n\015()] *                         #         normal*
1139 )*                                  #            )*
1140 \)                             #                )
1141 [\040\t]* )*    # If comment found, allow more spaces.
1142 (?:
1143 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1144 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1145 # Atom
1146 |                       #  or
1147 "                                     # "
1148 [^\\\x80-\xff\n\015"] *                            #   normal
1149 (?:  \\ [^\x80-\xff]  [^\\\x80-\xff\n\015"] * )*        #   ( special normal* )*
1150 "                                     #        "
1151 # Quoted string
1152 )
1153 [\040\t]*                    # Nab whitespace.
1154 (?:
1155 \(                              #  (
1156 [^\\\x80-\xff\n\015()] *                             #     normal*
1157 (?:                                 #       (
1158 (?:  \\ [^\x80-\xff]  |
1159 \(                            #  (
1160 [^\\\x80-\xff\n\015()] *                            #     normal*
1161 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1162 \)                           #                       )
1163 )    #         special
1164 [^\\\x80-\xff\n\015()] *                         #         normal*
1165 )*                                  #            )*
1166 \)                             #                )
1167 [\040\t]* )*    # If comment found, allow more spaces.
1168 # additional words
1169 )*
1170 @
1171 [\040\t]*                    # Nab whitespace.
1172 (?:
1173 \(                              #  (
1174 [^\\\x80-\xff\n\015()] *                             #     normal*
1175 (?:                                 #       (
1176 (?:  \\ [^\x80-\xff]  |
1177 \(                            #  (
1178 [^\\\x80-\xff\n\015()] *                            #     normal*
1179 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1180 \)                           #                       )
1181 )    #         special
1182 [^\\\x80-\xff\n\015()] *                         #         normal*
1183 )*                                  #            )*
1184 \)                             #                )
1185 [\040\t]* )*    # If comment found, allow more spaces.
1186 (?:
1187 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1188 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1189 |
1190 \[                            # [
1191 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1192 \]                           #           ]
1193 )
1194 [\040\t]*                    # Nab whitespace.
1195 (?:
1196 \(                              #  (
1197 [^\\\x80-\xff\n\015()] *                             #     normal*
1198 (?:                                 #       (
1199 (?:  \\ [^\x80-\xff]  |
1200 \(                            #  (
1201 [^\\\x80-\xff\n\015()] *                            #     normal*
1202 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1203 \)                           #                       )
1204 )    #         special
1205 [^\\\x80-\xff\n\015()] *                         #         normal*
1206 )*                                  #            )*
1207 \)                             #                )
1208 [\040\t]* )*    # If comment found, allow more spaces.
1209 # optional trailing comments
1210 (?:
1211 \.
1212 [\040\t]*                    # Nab whitespace.
1213 (?:
1214 \(                              #  (
1215 [^\\\x80-\xff\n\015()] *                             #     normal*
1216 (?:                                 #       (
1217 (?:  \\ [^\x80-\xff]  |
1218 \(                            #  (
1219 [^\\\x80-\xff\n\015()] *                            #     normal*
1220 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1221 \)                           #                       )
1222 )    #         special
1223 [^\\\x80-\xff\n\015()] *                         #         normal*
1224 )*                                  #            )*
1225 \)                             #                )
1226 [\040\t]* )*    # If comment found, allow more spaces.
1227 (?:
1228 [^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+    # some number of atom characters...
1229 (?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1230 |
1231 \[                            # [
1232 (?: [^\\\x80-\xff\n\015\[\]] |  \\ [^\x80-\xff]  )*     #    stuff
1233 \]                           #           ]
1234 )
1235 [\040\t]*                    # Nab whitespace.
1236 (?:
1237 \(                              #  (
1238 [^\\\x80-\xff\n\015()] *                             #     normal*
1239 (?:                                 #       (
1240 (?:  \\ [^\x80-\xff]  |
1241 \(                            #  (
1242 [^\\\x80-\xff\n\015()] *                            #     normal*
1243 (?:  \\ [^\x80-\xff]   [^\\\x80-\xff\n\015()] * )*        #     (special normal*)*
1244 \)                           #                       )
1245 )    #         special
1246 [^\\\x80-\xff\n\015()] *                         #         normal*
1247 )*                                  #            )*
1248 \)                             #                )
1249 [\040\t]* )*    # If comment found, allow more spaces.
1250 # optional trailing comments
1251 )*
1252 #       address spec
1253 >                    #                 >
1254 # name and address
1255 )
1256 /x
1257     Alan Other <user\@dom.ain>
1258     <user\@dom.ain>
1259     user\@dom.ain
1260     \"A. Other\" <user.1234\@dom.ain> (a comment)
1261     A. Other <user.1234\@dom.ain> (a comment)
1262     \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
1263     A missing angle <user\@some.where
1264     *** Failers
1265     The quick brown fox
1266
1267 /abc\0def\00pqr\000xyz\0000AB/
1268     abc\0def\00pqr\000xyz\0000AB
1269     abc456 abc\0def\00pqr\000xyz\0000ABCDE
1270
1271 /abc\x0def\x00pqr\x000xyz\x0000AB/
1272     abc\x0def\x00pqr\x000xyz\x0000AB
1273     abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
1274
1275 /^[\000-\037]/
1276     \0A
1277     \01B
1278     \037C
1279
1280 /\0*/
1281     \0\0\0\0
1282
1283 /A\x0{2,3}Z/
1284     The A\x0\x0Z
1285     An A\0\x0\0Z
1286     *** Failers
1287     A\0Z
1288     A\0\x0\0\x0Z
1289
1290 /^(cow|)\1(bell)/
1291     cowcowbell
1292     bell
1293     *** Failers
1294     cowbell
1295
1296 /^\s/
1297     \040abc
1298     \x0cabc
1299     \nabc
1300     \rabc
1301     \tabc
1302     *** Failers
1303     abc
1304
1305 /^a     b
1306     \f  c/x
1307     abc
1308
1309 /^(a|)\1*b/
1310     ab
1311     aaaab
1312     b
1313     *** Failers
1314     acb
1315
1316 /^(a|)\1+b/
1317     aab
1318     aaaab
1319     b
1320     *** Failers
1321     ab
1322
1323 /^(a|)\1?b/
1324     ab
1325     aab
1326     b
1327     *** Failers
1328     acb
1329
1330 /^(a|)\1{2}b/
1331     aaab
1332     b
1333     *** Failers
1334     ab
1335     aab
1336     aaaab
1337
1338 /^(a|)\1{2,3}b/
1339     aaab
1340     aaaab
1341     b
1342     *** Failers
1343     ab
1344     aab
1345     aaaaab
1346
1347 /ab{1,3}bc/
1348     abbbbc
1349     abbbc
1350     abbc
1351     *** Failers
1352     abc
1353     abbbbbc
1354
1355 /([^.]*)\.([^:]*):[T ]+(.*)/
1356     track1.title:TBlah blah blah
1357
1358 /([^.]*)\.([^:]*):[T ]+(.*)/i
1359     track1.title:TBlah blah blah
1360
1361 /([^.]*)\.([^:]*):[t ]+(.*)/i
1362     track1.title:TBlah blah blah
1363
1364 /^[W-c]+$/
1365     WXY_^abc
1366     *** Failers
1367     wxy
1368
1369 /^[W-c]+$/i
1370     WXY_^abc
1371     wxy_^ABC
1372
1373 /^[\x3f-\x5F]+$/i
1374     WXY_^abc
1375     wxy_^ABC
1376
1377 /^abc$/m
1378     abc
1379     qqq\nabc
1380     abc\nzzz
1381     qqq\nabc\nzzz
1382
1383 /^abc$/
1384     abc
1385     *** Failers
1386     qqq\nabc
1387     abc\nzzz
1388     qqq\nabc\nzzz
1389
1390 /\Aabc\Z/m
1391     abc
1392     abc\n 
1393     *** Failers
1394     qqq\nabc
1395     abc\nzzz
1396     qqq\nabc\nzzz
1397     
1398 /\A(.)*\Z/s
1399     abc\ndef
1400
1401 /\A(.)*\Z/m
1402     *** Failers
1403     abc\ndef
1404
1405 /(?:b)|(?::+)/
1406     b::c
1407     c::b
1408
1409 /[-az]+/
1410     az-
1411     *** Failers
1412     b
1413
1414 /[az-]+/
1415     za-
1416     *** Failers
1417     b
1418
1419 /[a\-z]+/
1420     a-z
1421     *** Failers
1422     b
1423
1424 /[a-z]+/
1425     abcdxyz
1426
1427 /[\d-]+/
1428     12-34
1429     *** Failers
1430     aaa
1431
1432 /[\d-z]+/
1433     12-34z
1434     *** Failers
1435     aaa
1436
1437 /\x5c/
1438     \\
1439
1440 /\x20Z/
1441     the Zoo
1442     *** Failers
1443     Zulu
1444
1445 /(abc)\1/i
1446     abcabc
1447     ABCabc
1448     abcABC
1449
1450 /ab{3cd/
1451     ab{3cd
1452
1453 /ab{3,cd/
1454     ab{3,cd
1455
1456 /ab{3,4a}cd/
1457     ab{3,4a}cd
1458
1459 /{4,5a}bc/
1460     {4,5a}bc
1461
1462 /abc$/
1463     abc
1464     abc\n
1465     *** Failers
1466     abc\ndef
1467
1468 /(abc)\123/
1469     abc\x53
1470
1471 /(abc)\223/
1472     abc\x93
1473
1474 /(abc)\323/
1475     abc\xd3
1476
1477 /(abc)\100/
1478     abc\x40
1479     abc\100
1480
1481 /(abc)\1000/
1482     abc\x400
1483     abc\x40\x30
1484     abc\1000
1485     abc\100\x30
1486     abc\100\060
1487     abc\100\60
1488     
1489 /^A\8B\9C$/
1490     A8B9C
1491     *** Failers
1492     A\08B\09C  
1493     
1494 /^(A)(B)(C)(D)(E)(F)(G)(H)(I)\8\9$/
1495     ABCDEFGHIHI 
1496
1497 /^[A\8B\9C]+$/
1498     A8B9C
1499     *** Failers 
1500     A8B9C\x00
1501
1502 /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\12\123/
1503     abcdefghijkllS
1504
1505 /(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
1506     abcdefghijk\12S
1507
1508 /ab\idef/
1509     abidef
1510
1511 /a{0}bc/
1512     bc
1513
1514 /(a|(bc)){0,0}?xyz/
1515     xyz
1516
1517 /abc[\10]de/
1518     abc\010de
1519
1520 /abc[\1]de/
1521     abc\1de
1522
1523 /(abc)[\1]de/
1524     abc\1de
1525
1526 /(?s)a.b/
1527     a\nb
1528
1529 /^([^a])([^\b])([^c]*)([^d]{3,4})/
1530     baNOTccccd
1531     baNOTcccd
1532     baNOTccd
1533     bacccd
1534     *** Failers
1535     anything
1536     b\bc   
1537     baccd
1538
1539 /[^a]/
1540     Abc
1541   
1542 /[^a]/i
1543     Abc 
1544
1545 /[^a]+/
1546     AAAaAbc
1547   
1548 /[^a]+/i
1549     AAAaAbc 
1550
1551 /[^a]+/
1552     bbb\nccc
1553    
1554 /[^k]$/
1555     abc
1556     *** Failers
1557     abk   
1558    
1559 /[^k]{2,3}$/
1560     abc
1561     kbc
1562     kabc 
1563     *** Failers
1564     abk
1565     akb
1566     akk 
1567
1568 /^\d{8,}\@.+[^k]$/
1569     12345678\@a.b.c.d
1570     123456789\@x.y.z
1571     *** Failers
1572     12345678\@x.y.uk
1573     1234567\@a.b.c.d       
1574
1575 /(a)\1{8,}/
1576     aaaaaaaaa
1577     aaaaaaaaaa
1578     *** Failers
1579     aaaaaaa   
1580
1581 /[^a]/
1582     aaaabcd
1583     aaAabcd 
1584
1585 /[^a]/i
1586     aaaabcd
1587     aaAabcd 
1588
1589 /[^az]/
1590     aaaabcd
1591     aaAabcd 
1592
1593 /[^az]/i
1594     aaaabcd
1595     aaAabcd 
1596
1597 /\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/
1598  \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
1599
1600 /P[^*]TAIRE[^*]{1,6}?LL/
1601     xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
1602
1603 /P[^*]TAIRE[^*]{1,}?LL/
1604     xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
1605
1606 /(\.\d\d[1-9]?)\d+/
1607     1.230003938
1608     1.875000282   
1609     1.235  
1610                   
1611 /(\.\d\d((?=0)|\d(?=\d)))/
1612     1.230003938      
1613     1.875000282
1614     *** Failers 
1615     1.235 
1616     
1617 /a(?)b/
1618     ab 
1619  
1620 /\b(foo)\s+(\w+)/i
1621     Food is on the foo table
1622     
1623 /foo(.*)bar/
1624     The food is under the bar in the barn.
1625     
1626 /foo(.*?)bar/  
1627     The food is under the bar in the barn.
1628
1629 /(.*)(\d*)/
1630     I have 2 numbers: 53147
1631     
1632 /(.*)(\d+)/
1633     I have 2 numbers: 53147
1634  
1635 /(.*?)(\d*)/
1636     I have 2 numbers: 53147
1637
1638 /(.*?)(\d+)/
1639     I have 2 numbers: 53147
1640
1641 /(.*)(\d+)$/
1642     I have 2 numbers: 53147
1643
1644 /(.*?)(\d+)$/
1645     I have 2 numbers: 53147
1646
1647 /(.*)\b(\d+)$/
1648     I have 2 numbers: 53147
1649
1650 /(.*\D)(\d+)$/
1651     I have 2 numbers: 53147
1652
1653 /^\D*(?!123)/
1654     ABC123
1655      
1656 /^(\D*)(?=\d)(?!123)/
1657     ABC445
1658     *** Failers
1659     ABC123
1660     
1661 /^[W-]46]/
1662     W46]789 
1663     -46]789
1664     *** Failers
1665     Wall
1666     Zebra
1667     42
1668     [abcd] 
1669     ]abcd[
1670        
1671 /^[W-\]46]/
1672     W46]789 
1673     Wall
1674     Zebra
1675     Xylophone  
1676     42
1677     [abcd] 
1678     ]abcd[
1679     \\backslash 
1680     *** Failers
1681     -46]789
1682     well
1683     
1684 /\d\d\/\d\d\/\d\d\d\d/
1685     01/01/2000
1686
1687 /word (?:[a-zA-Z0-9]+ ){0,10}otherword/
1688   word cat dog elephant mussel cow horse canary baboon snake shark otherword
1689   word cat dog elephant mussel cow horse canary baboon snake shark
1690
1691 /word (?:[a-zA-Z0-9]+ ){0,300}otherword/
1692   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
1693
1694 /^(a){0,0}/
1695     bcd
1696     abc
1697     aab     
1698
1699 /^(a){0,1}/
1700     bcd
1701     abc
1702     aab  
1703
1704 /^(a){0,2}/
1705     bcd
1706     abc
1707     aab  
1708
1709 /^(a){0,3}/
1710     bcd
1711     abc
1712     aab
1713     aaa   
1714
1715 /^(a){0,}/
1716     bcd
1717     abc
1718     aab
1719     aaa
1720     aaaaaaaa    
1721
1722 /^(a){1,1}/
1723     bcd
1724     abc
1725     aab  
1726
1727 /^(a){1,2}/
1728     bcd
1729     abc
1730     aab  
1731
1732 /^(a){1,3}/
1733     bcd
1734     abc
1735     aab
1736     aaa   
1737
1738 /^(a){1,}/
1739     bcd
1740     abc
1741     aab
1742     aaa
1743     aaaaaaaa    
1744
1745 /.*\.gif/
1746     borfle\nbib.gif\nno
1747
1748 /.{0,}\.gif/
1749     borfle\nbib.gif\nno
1750
1751 /.*\.gif/m
1752     borfle\nbib.gif\nno
1753
1754 /.*\.gif/s
1755     borfle\nbib.gif\nno
1756
1757 /.*\.gif/ms
1758     borfle\nbib.gif\nno
1759     
1760 /.*$/
1761     borfle\nbib.gif\nno
1762
1763 /.*$/m
1764     borfle\nbib.gif\nno
1765
1766 /.*$/s
1767     borfle\nbib.gif\nno
1768
1769 /.*$/ms
1770     borfle\nbib.gif\nno
1771     
1772 /.*$/
1773     borfle\nbib.gif\nno\n
1774
1775 /.*$/m
1776     borfle\nbib.gif\nno\n
1777
1778 /.*$/s
1779     borfle\nbib.gif\nno\n
1780
1781 /.*$/ms
1782     borfle\nbib.gif\nno\n
1783     
1784 /(.*X|^B)/
1785     abcde\n1234Xyz
1786     BarFoo 
1787     *** Failers
1788     abcde\nBar  
1789
1790 /(.*X|^B)/m
1791     abcde\n1234Xyz
1792     BarFoo 
1793     abcde\nBar  
1794
1795 /(.*X|^B)/s
1796     abcde\n1234Xyz
1797     BarFoo 
1798     *** Failers
1799     abcde\nBar  
1800
1801 /(.*X|^B)/ms
1802     abcde\n1234Xyz
1803     BarFoo 
1804     abcde\nBar  
1805
1806 /(?s)(.*X|^B)/
1807     abcde\n1234Xyz
1808     BarFoo 
1809     *** Failers 
1810     abcde\nBar  
1811
1812 /(?s:.*X|^B)/
1813     abcde\n1234Xyz
1814     BarFoo 
1815     *** Failers 
1816     abcde\nBar  
1817
1818 /^.*B/
1819     **** Failers
1820     abc\nB
1821      
1822 /(?s)^.*B/
1823     abc\nB
1824
1825 /(?m)^.*B/
1826     abc\nB
1827      
1828 /(?ms)^.*B/
1829     abc\nB
1830
1831 /(?ms)^B/
1832     abc\nB
1833
1834 /(?s)B$/
1835     B\n
1836
1837 /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
1838     123456654321
1839   
1840 /^\d\d\d\d\d\d\d\d\d\d\d\d/
1841     123456654321 
1842
1843 /^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
1844     123456654321
1845   
1846 /^[abc]{12}/
1847     abcabcabcabc
1848     
1849 /^[a-c]{12}/
1850     abcabcabcabc
1851     
1852 /^(a|b|c){12}/
1853     abcabcabcabc 
1854
1855 /^[abcdefghijklmnopqrstuvwxy0123456789]/
1856     n
1857     *** Failers 
1858     z 
1859
1860 /abcde{0,0}/
1861     abcd
1862     *** Failers
1863     abce  
1864
1865 /ab[cd]{0,0}e/
1866     abe
1867     *** Failers
1868     abcde 
1869     
1870 /ab(c){0,0}d/
1871     abd
1872     *** Failers
1873     abcd   
1874
1875 /a(b*)/
1876     a
1877     ab
1878     abbbb
1879     *** Failers
1880     bbbbb    
1881     
1882 /ab\d{0}e/
1883     abe
1884     *** Failers
1885     ab1e   
1886     
1887 /"([^\\"]+|\\.)*"/
1888     the \"quick\" brown fox
1889     \"the \\\"quick\\\" brown fox\" 
1890
1891 /.*?/g+
1892     abc
1893   
1894 /\b/g+
1895     abc 
1896
1897 /\b/+g
1898     abc 
1899
1900 //g
1901     abc
1902
1903 /<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
1904   <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>
1905
1906 /a[^a]b/
1907     acb
1908     a\nb
1909     
1910 /a.b/
1911     acb
1912     *** Failers 
1913     a\nb   
1914     
1915 /a[^a]b/s
1916     acb
1917     a\nb  
1918     
1919 /a.b/s
1920     acb
1921     a\nb  
1922
1923 /^(b+?|a){1,2}?c/
1924     bac
1925     bbac
1926     bbbac
1927     bbbbac
1928     bbbbbac 
1929
1930 /^(b+|a){1,2}?c/
1931     bac
1932     bbac
1933     bbbac
1934     bbbbac
1935     bbbbbac 
1936     
1937 /(?!\A)x/m
1938     x\nb\n
1939     a\bx\n  
1940     
1941 /\x0{ab}/
1942     \0{ab} 
1943
1944 /(A|B)*?CD/
1945     CD 
1946     
1947 /(A|B)*CD/
1948     CD 
1949
1950 /(AB)*?\1/
1951     ABABAB
1952
1953 /(AB)*\1/
1954     ABABAB
1955     
1956 /(?<!bar)foo/
1957     foo
1958     catfood
1959     arfootle
1960     rfoosh
1961     *** Failers
1962     barfoo
1963     towbarfoo
1964
1965 /\w{3}(?<!bar)foo/
1966     catfood
1967     *** Failers
1968     foo
1969     barfoo
1970     towbarfoo
1971
1972 /(?<=(foo)a)bar/
1973     fooabar
1974     *** Failers
1975     bar
1976     foobbar
1977       
1978 /\Aabc\z/m
1979     abc
1980     *** Failers
1981     abc\n   
1982     qqq\nabc
1983     abc\nzzz
1984     qqq\nabc\nzzz
1985
1986 "(?>.*/)foo"
1987     /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
1988
1989 "(?>.*/)foo"
1990     /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
1991
1992 /(?>(\.\d\d[1-9]?))\d+/
1993     1.230003938
1994     1.875000282
1995     *** Failers 
1996     1.235 
1997
1998 /^((?>\w+)|(?>\s+))*$/
1999     now is the time for all good men to come to the aid of the party
2000     *** Failers
2001     this is not a line with only words and spaces!
2002     
2003 /(\d+)(\w)/
2004     12345a
2005     12345+ 
2006
2007 /((?>\d+))(\w)/
2008     12345a
2009     *** Failers
2010     12345+ 
2011
2012 /(?>a+)b/
2013     aaab
2014
2015 /((?>a+)b)/
2016     aaab
2017
2018 /(?>(a+))b/
2019     aaab
2020
2021 /(?>b)+/
2022     aaabbbccc
2023
2024 /(?>a+|b+|c+)*c/
2025     aaabbbbccccd
2026
2027 /((?>[^()]+)|\([^()]*\))+/
2028     ((abc(ade)ufh()()x
2029     
2030 /\(((?>[^()]+)|\([^()]+\))+\)/ 
2031     (abc)
2032     (abc(def)xyz)
2033     *** Failers
2034     ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa   
2035
2036 /a(?-i)b/i
2037     ab
2038     Ab
2039     *** Failers 
2040     aB
2041     AB
2042         
2043 /(a (?x)b c)d e/
2044     a bcd e
2045     *** Failers
2046     a b cd e
2047     abcd e   
2048     a bcde 
2049  
2050 /(a b(?x)c d (?-x)e f)/
2051     a bcde f
2052     *** Failers
2053     abcdef  
2054
2055 /(a(?i)b)c/
2056     abc
2057     aBc
2058     *** Failers
2059     abC
2060     aBC  
2061     Abc
2062     ABc
2063     ABC
2064     AbC
2065     
2066 /a(?i:b)c/
2067     abc
2068     aBc
2069     *** Failers 
2070     ABC
2071     abC
2072     aBC
2073     
2074 /a(?i:b)*c/
2075     aBc
2076     aBBc
2077     *** Failers 
2078     aBC
2079     aBBC
2080     
2081 /a(?=b(?i)c)\w\wd/
2082     abcd
2083     abCd
2084     *** Failers
2085     aBCd
2086     abcD     
2087     
2088 /(?s-i:more.*than).*million/i
2089     more than million
2090     more than MILLION
2091     more \n than Million 
2092     *** Failers
2093     MORE THAN MILLION    
2094     more \n than \n million 
2095
2096 /(?:(?s-i)more.*than).*million/i
2097     more than million
2098     more than MILLION
2099     more \n than Million 
2100     *** Failers
2101     MORE THAN MILLION    
2102     more \n than \n million 
2103     
2104 /(?>a(?i)b+)+c/ 
2105     abc
2106     aBbc
2107     aBBc 
2108     *** Failers
2109     Abc
2110     abAb    
2111     abbC 
2112     
2113 /(?=a(?i)b)\w\wc/
2114     abc
2115     aBc
2116     *** Failers
2117     Ab 
2118     abC
2119     aBC     
2120     
2121 /(?<=a(?i)b)(\w\w)c/
2122     abxxc
2123     aBxxc
2124     *** Failers
2125     Abxxc
2126     ABxxc
2127     abxxC      
2128
2129 /(?:(a)|b)(?(1)A|B)/
2130     aA
2131     bB
2132     *** Failers
2133     aB
2134     bA    
2135
2136 /^(a)?(?(1)a|b)+$/
2137     aa
2138     b
2139     bb  
2140     *** Failers
2141     ab   
2142
2143 /^(?(?=abc)\w{3}:|\d\d)$/
2144     abc:
2145     12
2146     *** Failers
2147     123
2148     xyz    
2149
2150 /^(?(?!abc)\d\d|\w{3}:)$/
2151     abc:
2152     12
2153     *** Failers
2154     123
2155     xyz    
2156     
2157 /(?(?<=foo)bar|cat)/
2158     foobar
2159     cat
2160     fcat
2161     focat   
2162     *** Failers
2163     foocat  
2164
2165 /(?(?<!foo)cat|bar)/
2166     foobar
2167     cat
2168     fcat
2169     focat   
2170     *** Failers
2171     foocat  
2172
2173 /( \( )? [^()]+ (?(1) \) |) /x
2174     abcd
2175     (abcd)
2176     the quick (abcd) fox
2177     (abcd   
2178
2179 /( \( )? [^()]+ (?(1) \) ) /x
2180     abcd
2181     (abcd)
2182     the quick (abcd) fox
2183     (abcd   
2184
2185 /^(?(2)a|(1)(2))+$/
2186     12
2187     12a
2188     12aa
2189     *** Failers
2190     1234    
2191
2192 /((?i)blah)\s+\1/
2193     blah blah
2194     BLAH BLAH
2195     Blah Blah
2196     blaH blaH
2197     *** Failers
2198     blah BLAH
2199     Blah blah      
2200     blaH blah 
2201
2202 /((?i)blah)\s+(?i:\1)/
2203     blah blah
2204     BLAH BLAH
2205     Blah Blah
2206     blaH blaH
2207     blah BLAH
2208     Blah blah      
2209     blaH blah 
2210
2211 /(?>a*)*/
2212     a
2213     aa
2214     aaaa
2215     
2216 /(abc|)+/
2217     abc
2218     abcabc
2219     abcabcabc
2220     xyz      
2221
2222 /([a]*)*/
2223     a
2224     aaaaa 
2225  
2226 /([ab]*)*/
2227     a
2228     b
2229     ababab
2230     aaaabcde
2231     bbbb    
2232  
2233 /([^a]*)*/
2234     b
2235     bbbb
2236     aaa   
2237  
2238 /([^ab]*)*/
2239     cccc
2240     abab  
2241  
2242 /([a]*?)*/
2243     a
2244     aaaa 
2245  
2246 /([ab]*?)*/
2247     a
2248     b
2249     abab
2250     baba   
2251  
2252 /([^a]*?)*/
2253     b
2254     bbbb
2255     aaa   
2256  
2257 /([^ab]*?)*/
2258     c
2259     cccc
2260     baba   
2261  
2262 /(?>a*)*/
2263     a
2264     aaabcde 
2265  
2266 /((?>a*))*/
2267     aaaaa
2268     aabbaa 
2269  
2270 /((?>a*?))*/
2271     aaaaa
2272     aabbaa 
2273
2274 /(?(?=[^a-z]+[a-z])  \d{2}-[a-z]{3}-\d{2}  |  \d{2}-\d{2}-\d{2} ) /x
2275     12-sep-98
2276     12-09-98
2277     *** Failers
2278     sep-12-98
2279         
2280 /(?<=(foo))bar\1/
2281     foobarfoo
2282     foobarfootling 
2283     *** Failers
2284     foobar
2285     barfoo   
2286
2287 /(?i:saturday|sunday)/
2288     saturday
2289     sunday
2290     Saturday
2291     Sunday
2292     SATURDAY
2293     SUNDAY
2294     SunDay
2295     
2296 /(a(?i)bc|BB)x/
2297     abcx
2298     aBCx
2299     bbx
2300     BBx
2301     *** Failers
2302     abcX
2303     aBCX
2304     bbX
2305     BBX               
2306
2307 /^([ab](?i)[cd]|[ef])/
2308     ac
2309     aC
2310     bD
2311     elephant
2312     Europe 
2313     frog
2314     France
2315     *** Failers
2316     Africa     
2317
2318 /^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
2319     ab
2320     aBd
2321     xy
2322     xY
2323     zebra
2324     Zambesi
2325     *** Failers
2326     aCD  
2327     XY  
2328
2329 /(?<=foo\n)^bar/m
2330     foo\nbar
2331     *** Failers
2332     bar
2333     baz\nbar   
2334
2335 /(?<=(?<!foo)bar)baz/
2336     barbaz
2337     barbarbaz 
2338     koobarbaz 
2339     *** Failers
2340     baz
2341     foobarbaz 
2342
2343 /The cases of aaaa and aaaaaa are missed out below because Perl does things/
2344 /differently. We know that odd, and maybe incorrect, things happen with/
2345 /recursive references in Perl, as far as 5.11.3 - see some stuff in test #2./
2346
2347 /^(a\1?){4}$/
2348     a
2349     aa
2350     aaa
2351     aaaaa
2352     aaaaaaa
2353     aaaaaaaa
2354     aaaaaaaaa
2355     aaaaaaaaaa
2356     aaaaaaaaaaa
2357     aaaaaaaaaaaa
2358     aaaaaaaaaaaaa
2359     aaaaaaaaaaaaaa
2360     aaaaaaaaaaaaaaa
2361     aaaaaaaaaaaaaaaa               
2362
2363 /^(a\1?)(a\1?)(a\2?)(a\3?)$/
2364     a
2365     aa
2366     aaa
2367     aaaa
2368     aaaaa
2369     aaaaaa
2370     aaaaaaa
2371     aaaaaaaa
2372     aaaaaaaaa
2373     aaaaaaaaaa
2374     aaaaaaaaaaa
2375     aaaaaaaaaaaa
2376     aaaaaaaaaaaaa
2377     aaaaaaaaaaaaaa
2378     aaaaaaaaaaaaaaa
2379     aaaaaaaaaaaaaaaa               
2380
2381 /The following tests are taken from the Perl 5.005 test suite; some of them/
2382 /are compatible with 5.004, but I'd rather not have to sort them out./
2383
2384 /abc/
2385     abc
2386     xabcy
2387     ababc
2388     *** Failers
2389     xbc
2390     axc
2391     abx
2392
2393 /ab*c/
2394     abc
2395
2396 /ab*bc/
2397     abc
2398     abbc
2399     abbbbc
2400
2401 /.{1}/
2402     abbbbc
2403
2404 /.{3,4}/
2405     abbbbc
2406
2407 /ab{0,}bc/
2408     abbbbc
2409
2410 /ab+bc/
2411     abbc
2412     *** Failers
2413     abc
2414     abq
2415
2416 /ab{1,}bc/
2417
2418 /ab+bc/
2419     abbbbc
2420
2421 /ab{1,}bc/
2422     abbbbc
2423
2424 /ab{1,3}bc/
2425     abbbbc
2426
2427 /ab{3,4}bc/
2428     abbbbc
2429
2430 /ab{4,5}bc/
2431     *** Failers
2432     abq
2433     abbbbc
2434
2435 /ab?bc/
2436     abbc
2437     abc
2438
2439 /ab{0,1}bc/
2440     abc
2441
2442 /ab?bc/
2443
2444 /ab?c/
2445     abc
2446
2447 /ab{0,1}c/
2448     abc
2449
2450 /^abc$/
2451     abc
2452     *** Failers
2453     abbbbc
2454     abcc
2455
2456 /^abc/
2457     abcc
2458
2459 /^abc$/
2460
2461 /abc$/
2462     aabc
2463     *** Failers
2464     aabc
2465     aabcd
2466
2467 /^/
2468     abc
2469
2470 /$/
2471     abc
2472
2473 /a.c/
2474     abc
2475     axc
2476
2477 /a.*c/
2478     axyzc
2479
2480 /a[bc]d/
2481     abd
2482     *** Failers
2483     axyzd
2484     abc
2485
2486 /a[b-d]e/
2487     ace
2488
2489 /a[b-d]/
2490     aac
2491
2492 /a[-b]/
2493     a-
2494
2495 /a[b-]/
2496     a-
2497
2498 /a]/
2499     a]
2500
2501 /a[]]b/
2502     a]b
2503
2504 /a[^bc]d/
2505     aed
2506     *** Failers
2507     abd
2508     abd
2509
2510 /a[^-b]c/
2511     adc
2512
2513 /a[^]b]c/
2514     adc
2515     *** Failers
2516     a-c
2517     a]c
2518
2519 /\ba\b/
2520     a-
2521     -a
2522     -a-
2523
2524 /\by\b/
2525     *** Failers
2526     xy
2527     yz
2528     xyz
2529
2530 /\Ba\B/
2531     *** Failers
2532     a-
2533     -a
2534     -a-
2535
2536 /\By\b/
2537     xy
2538
2539 /\by\B/
2540     yz
2541
2542 /\By\B/
2543     xyz
2544
2545 /\w/
2546     a
2547
2548 /\W/
2549     -
2550     *** Failers
2551     -
2552     a
2553
2554 /a\sb/
2555     a b
2556
2557 /a\Sb/
2558     a-b
2559     *** Failers
2560     a-b
2561     a b
2562
2563 /\d/
2564     1
2565
2566 /\D/
2567     -
2568     *** Failers
2569     -
2570     1
2571
2572 /[\w]/
2573     a
2574
2575 /[\W]/
2576     -
2577     *** Failers
2578     -
2579     a
2580
2581 /a[\s]b/
2582     a b
2583
2584 /a[\S]b/
2585     a-b
2586     *** Failers
2587     a-b
2588     a b
2589
2590 /[\d]/
2591     1
2592
2593 /[\D]/
2594     -
2595     *** Failers
2596     -
2597     1
2598
2599 /ab|cd/
2600     abc
2601     abcd
2602
2603 /()ef/
2604     def
2605
2606 /$b/
2607
2608 /a\(b/
2609     a(b
2610
2611 /a\(*b/
2612     ab
2613     a((b
2614
2615 /a\\b/
2616     a\b
2617
2618 /((a))/
2619     abc
2620
2621 /(a)b(c)/
2622     abc
2623
2624 /a+b+c/
2625     aabbabc
2626
2627 /a{1,}b{1,}c/
2628     aabbabc
2629
2630 /a.+?c/
2631     abcabc
2632
2633 /(a+|b)*/
2634     ab
2635
2636 /(a+|b){0,}/
2637     ab
2638
2639 /(a+|b)+/
2640     ab
2641
2642 /(a+|b){1,}/
2643     ab
2644
2645 /(a+|b)?/
2646     ab
2647
2648 /(a+|b){0,1}/
2649     ab
2650
2651 /[^ab]*/
2652     cde
2653
2654 /abc/
2655     *** Failers
2656     b
2657     
2658
2659 /a*/
2660     
2661
2662 /([abc])*d/
2663     abbbcd
2664
2665 /([abc])*bcd/
2666     abcd
2667
2668 /a|b|c|d|e/
2669     e
2670
2671 /(a|b|c|d|e)f/
2672     ef
2673
2674 /abcd*efg/
2675     abcdefg
2676
2677 /ab*/
2678     xabyabbbz
2679     xayabbbz
2680
2681 /(ab|cd)e/
2682     abcde
2683
2684 /[abhgefdc]ij/
2685     hij
2686
2687 /^(ab|cd)e/
2688
2689 /(abc|)ef/
2690     abcdef
2691
2692 /(a|b)c*d/
2693     abcd
2694
2695 /(ab|ab*)bc/
2696     abc
2697
2698 /a([bc]*)c*/
2699     abc
2700
2701 /a([bc]*)(c*d)/
2702     abcd
2703
2704 /a([bc]+)(c*d)/
2705     abcd
2706
2707 /a([bc]*)(c+d)/
2708     abcd
2709
2710 /a[bcd]*dcdcde/
2711     adcdcde
2712
2713 /a[bcd]+dcdcde/
2714     *** Failers
2715     abcde
2716     adcdcde
2717
2718 /(ab|a)b*c/
2719     abc
2720
2721 /((a)(b)c)(d)/
2722     abcd
2723
2724 /[a-zA-Z_][a-zA-Z0-9_]*/
2725     alpha
2726
2727 /^a(bc+|b[eh])g|.h$/
2728     abh
2729
2730 /(bc+d$|ef*g.|h?i(j|k))/
2731     effgz
2732     ij
2733     reffgz
2734     *** Failers
2735     effg
2736     bcdd
2737
2738 /((((((((((a))))))))))/
2739     a
2740
2741 /((((((((((a))))))))))\10/
2742     aa
2743
2744 /(((((((((a)))))))))/
2745     a
2746
2747 /multiple words of text/
2748     *** Failers
2749     aa
2750     uh-uh
2751
2752 /multiple words/
2753     multiple words, yeah
2754
2755 /(.*)c(.*)/
2756     abcde
2757
2758 /\((.*), (.*)\)/
2759     (a, b)
2760
2761 /[k]/
2762
2763 /abcd/
2764     abcd
2765
2766 /a(bc)d/
2767     abcd
2768
2769 /a[-]?c/
2770     ac
2771
2772 /(abc)\1/
2773     abcabc
2774
2775 /([a-c]*)\1/
2776     abcabc
2777
2778 /(a)|\1/
2779     a
2780     *** Failers
2781     ab
2782     x
2783
2784 /(([a-c])b*?\2)*/
2785     ababbbcbc
2786
2787 /(([a-c])b*?\2){3}/
2788     ababbbcbc
2789
2790 /((\3|b)\2(a)x)+/
2791     aaaxabaxbaaxbbax
2792
2793 /((\3|b)\2(a)){2,}/
2794     bbaababbabaaaaabbaaaabba
2795
2796 /abc/i
2797     ABC
2798     XABCY
2799     ABABC
2800     *** Failers
2801     aaxabxbaxbbx
2802     XBC
2803     AXC
2804     ABX
2805
2806 /ab*c/i
2807     ABC
2808
2809 /ab*bc/i
2810     ABC
2811     ABBC
2812
2813 /ab*?bc/i
2814     ABBBBC
2815
2816 /ab{0,}?bc/i
2817     ABBBBC
2818
2819 /ab+?bc/i
2820     ABBC
2821
2822 /ab+bc/i
2823     *** Failers
2824     ABC
2825     ABQ
2826
2827 /ab{1,}bc/i
2828
2829 /ab+bc/i
2830     ABBBBC
2831
2832 /ab{1,}?bc/i
2833     ABBBBC
2834
2835 /ab{1,3}?bc/i
2836     ABBBBC
2837
2838 /ab{3,4}?bc/i
2839     ABBBBC
2840
2841 /ab{4,5}?bc/i
2842     *** Failers
2843     ABQ
2844     ABBBBC
2845
2846 /ab??bc/i
2847     ABBC
2848     ABC
2849
2850 /ab{0,1}?bc/i
2851     ABC
2852
2853 /ab??bc/i
2854
2855 /ab??c/i
2856     ABC
2857
2858 /ab{0,1}?c/i
2859     ABC
2860
2861 /^abc$/i
2862     ABC
2863     *** Failers
2864     ABBBBC
2865     ABCC
2866
2867 /^abc/i
2868     ABCC
2869
2870 /^abc$/i
2871
2872 /abc$/i
2873     AABC
2874
2875 /^/i
2876     ABC
2877
2878 /$/i
2879     ABC
2880
2881 /a.c/i
2882     ABC
2883     AXC
2884
2885 /a.*?c/i
2886     AXYZC
2887
2888 /a.*c/i
2889     *** Failers
2890     AABC
2891     AXYZD
2892
2893 /a[bc]d/i
2894     ABD
2895
2896 /a[b-d]e/i
2897     ACE
2898     *** Failers
2899     ABC
2900     ABD
2901
2902 /a[b-d]/i
2903     AAC
2904
2905 /a[-b]/i
2906     A-
2907
2908 /a[b-]/i
2909     A-
2910
2911 /a]/i
2912     A]
2913
2914 /a[]]b/i
2915     A]B
2916
2917 /a[^bc]d/i
2918     AED
2919
2920 /a[^-b]c/i
2921     ADC
2922     *** Failers
2923     ABD
2924     A-C
2925
2926 /a[^]b]c/i
2927     ADC
2928
2929 /ab|cd/i
2930     ABC
2931     ABCD
2932
2933 /()ef/i
2934     DEF
2935
2936 /$b/i
2937     *** Failers
2938     A]C
2939     B
2940
2941 /a\(b/i
2942     A(B
2943
2944 /a\(*b/i
2945     AB
2946     A((B
2947
2948 /a\\b/i
2949     A\B
2950
2951 /((a))/i
2952     ABC
2953
2954 /(a)b(c)/i
2955     ABC
2956
2957 /a+b+c/i
2958     AABBABC
2959
2960 /a{1,}b{1,}c/i
2961     AABBABC
2962
2963 /a.+?c/i
2964     ABCABC
2965
2966 /a.*?c/i
2967     ABCABC
2968
2969 /a.{0,5}?c/i
2970     ABCABC
2971
2972 /(a+|b)*/i
2973     AB
2974
2975 /(a+|b){0,}/i
2976     AB
2977
2978 /(a+|b)+/i
2979     AB
2980
2981 /(a+|b){1,}/i
2982     AB
2983
2984 /(a+|b)?/i
2985     AB
2986
2987 /(a+|b){0,1}/i
2988     AB
2989
2990 /(a+|b){0,1}?/i
2991     AB
2992
2993 /[^ab]*/i
2994     CDE
2995
2996 /abc/i
2997
2998 /a*/i
2999     
3000
3001 /([abc])*d/i
3002     ABBBCD
3003
3004 /([abc])*bcd/i
3005     ABCD
3006
3007 /a|b|c|d|e/i
3008     E
3009
3010 /(a|b|c|d|e)f/i
3011     EF
3012
3013 /abcd*efg/i
3014     ABCDEFG
3015
3016 /ab*/i
3017     XABYABBBZ
3018     XAYABBBZ
3019
3020 /(ab|cd)e/i
3021     ABCDE
3022
3023 /[abhgefdc]ij/i
3024     HIJ
3025
3026 /^(ab|cd)e/i
3027     ABCDE
3028
3029 /(abc|)ef/i
3030     ABCDEF
3031
3032 /(a|b)c*d/i
3033     ABCD
3034
3035 /(ab|ab*)bc/i
3036     ABC
3037
3038 /a([bc]*)c*/i
3039     ABC
3040
3041 /a([bc]*)(c*d)/i
3042     ABCD
3043
3044 /a([bc]+)(c*d)/i
3045     ABCD
3046
3047 /a([bc]*)(c+d)/i
3048     ABCD
3049
3050 /a[bcd]*dcdcde/i
3051     ADCDCDE
3052
3053 /a[bcd]+dcdcde/i
3054
3055 /(ab|a)b*c/i
3056     ABC
3057
3058 /((a)(b)c)(d)/i
3059     ABCD
3060
3061 /[a-zA-Z_][a-zA-Z0-9_]*/i
3062     ALPHA
3063
3064 /^a(bc+|b[eh])g|.h$/i
3065     ABH
3066
3067 /(bc+d$|ef*g.|h?i(j|k))/i
3068     EFFGZ
3069     IJ
3070     REFFGZ
3071     *** Failers
3072     ADCDCDE
3073     EFFG
3074     BCDD
3075
3076 /((((((((((a))))))))))/i
3077     A
3078
3079 /((((((((((a))))))))))\10/i
3080     AA
3081
3082 /(((((((((a)))))))))/i
3083     A
3084
3085 /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
3086     A
3087
3088 /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
3089     C
3090
3091 /multiple words of text/i
3092     *** Failers
3093     AA
3094     UH-UH
3095
3096 /multiple words/i
3097     MULTIPLE WORDS, YEAH
3098
3099 /(.*)c(.*)/i
3100     ABCDE
3101
3102 /\((.*), (.*)\)/i
3103     (A, B)
3104
3105 /[k]/i
3106
3107 /abcd/i
3108     ABCD
3109
3110 /a(bc)d/i
3111     ABCD
3112
3113 /a[-]?c/i
3114     AC
3115
3116 /(abc)\1/i
3117     ABCABC
3118
3119 /([a-c]*)\1/i
3120     ABCABC
3121
3122 /a(?!b)./
3123     abad
3124
3125 /a(?=d)./
3126     abad
3127
3128 /a(?=c|d)./
3129     abad
3130
3131 /a(?:b|c|d)(.)/
3132     ace
3133
3134 /a(?:b|c|d)*(.)/
3135     ace
3136
3137 /a(?:b|c|d)+?(.)/
3138     ace
3139     acdbcdbe
3140
3141 /a(?:b|c|d)+(.)/
3142     acdbcdbe
3143
3144 /a(?:b|c|d){2}(.)/
3145     acdbcdbe
3146
3147 /a(?:b|c|d){4,5}(.)/
3148     acdbcdbe
3149
3150 /a(?:b|c|d){4,5}?(.)/
3151     acdbcdbe
3152
3153 /((foo)|(bar))*/
3154     foobar
3155
3156 /a(?:b|c|d){6,7}(.)/
3157     acdbcdbe
3158
3159 /a(?:b|c|d){6,7}?(.)/
3160     acdbcdbe
3161
3162 /a(?:b|c|d){5,6}(.)/
3163     acdbcdbe
3164
3165 /a(?:b|c|d){5,6}?(.)/
3166     acdbcdbe
3167
3168 /a(?:b|c|d){5,7}(.)/
3169     acdbcdbe
3170
3171 /a(?:b|c|d){5,7}?(.)/
3172     acdbcdbe
3173
3174 /a(?:b|(c|e){1,2}?|d)+?(.)/
3175     ace
3176
3177 /^(.+)?B/
3178     AB
3179
3180 /^([^a-z])|(\^)$/
3181     .
3182
3183 /^[<>]&/
3184     <&OUT
3185
3186 /^(a\1?){4}$/
3187     aaaaaaaaaa
3188     *** Failers
3189     AB
3190     aaaaaaaaa
3191     aaaaaaaaaaa
3192
3193 /^(a(?(1)\1)){4}$/
3194     aaaaaaaaaa
3195     *** Failers
3196     aaaaaaaaa
3197     aaaaaaaaaaa
3198
3199 /(?:(f)(o)(o)|(b)(a)(r))*/
3200     foobar
3201
3202 /(?<=a)b/
3203     ab
3204     *** Failers
3205     cb
3206     b
3207
3208 /(?<!c)b/
3209     ab
3210     b
3211     b
3212
3213 /(?:..)*a/
3214     aba
3215
3216 /(?:..)*?a/
3217     aba
3218
3219 /^(?:b|a(?=(.)))*\1/
3220     abc
3221
3222 /^(){3,5}/
3223     abc
3224
3225 /^(a+)*ax/
3226     aax
3227
3228 /^((a|b)+)*ax/
3229     aax
3230
3231 /^((a|bc)+)*ax/
3232     aax
3233
3234 /(a|x)*ab/
3235     cab
3236
3237 /(a)*ab/
3238     cab
3239
3240 /(?:(?i)a)b/
3241     ab
3242
3243 /((?i)a)b/
3244     ab
3245
3246 /(?:(?i)a)b/
3247     Ab
3248
3249 /((?i)a)b/
3250     Ab
3251
3252 /(?:(?i)a)b/
3253     *** Failers
3254     cb
3255     aB
3256
3257 /((?i)a)b/
3258
3259 /(?i:a)b/
3260     ab
3261
3262 /((?i:a))b/
3263     ab
3264
3265 /(?i:a)b/
3266     Ab
3267
3268 /((?i:a))b/
3269     Ab
3270
3271 /(?i:a)b/
3272     *** Failers
3273     aB
3274     aB
3275
3276 /((?i:a))b/
3277
3278 /(?:(?-i)a)b/i
3279     ab
3280
3281 /((?-i)a)b/i
3282     ab
3283
3284 /(?:(?-i)a)b/i
3285     aB
3286
3287 /((?-i)a)b/i
3288     aB
3289
3290 /(?:(?-i)a)b/i
3291     *** Failers
3292     aB
3293     Ab
3294
3295 /((?-i)a)b/i
3296
3297 /(?:(?-i)a)b/i
3298     aB
3299
3300 /((?-i)a)b/i
3301     aB
3302
3303 /(?:(?-i)a)b/i
3304     *** Failers
3305     Ab
3306     AB
3307
3308 /((?-i)a)b/i
3309
3310 /(?-i:a)b/i
3311     ab
3312
3313 /((?-i:a))b/i
3314     ab
3315
3316 /(?-i:a)b/i
3317     aB
3318
3319 /((?-i:a))b/i
3320     aB
3321
3322 /(?-i:a)b/i
3323     *** Failers
3324     AB
3325     Ab
3326
3327 /((?-i:a))b/i
3328
3329 /(?-i:a)b/i
3330     aB
3331
3332 /((?-i:a))b/i
3333     aB
3334
3335 /(?-i:a)b/i
3336     *** Failers
3337     Ab
3338     AB
3339
3340 /((?-i:a))b/i
3341
3342 /((?-i:a.))b/i
3343     *** Failers
3344     AB
3345     a\nB
3346
3347 /((?s-i:a.))b/i
3348     a\nB
3349
3350 /(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
3351     cabbbb
3352
3353 /(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
3354     caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
3355
3356 /(ab)\d\1/i
3357     Ab4ab
3358     ab4Ab
3359
3360 /foo\w*\d{4}baz/
3361     foobar1234baz
3362
3363 /x(~~)*(?:(?:F)?)?/
3364     x~~
3365
3366 /^a(?#xxx){3}c/
3367     aaac
3368
3369 /^a (?#xxx) (?#yyy) {3}c/x
3370     aaac
3371
3372 /(?<![cd])b/
3373     *** Failers
3374     B\nB
3375     dbcb
3376
3377 /(?<![cd])[ab]/
3378     dbaacb
3379
3380 /(?<!(c|d))b/
3381
3382 /(?<!(c|d))[ab]/
3383     dbaacb
3384
3385 /(?<!cd)[ab]/
3386     cdaccb
3387
3388 /^(?:a?b?)*$/
3389     \
3390     a
3391     ab
3392     aaa   
3393     *** Failers
3394     dbcb
3395     a--
3396     aa-- 
3397
3398 /((?s)^a(.))((?m)^b$)/
3399     a\nb\nc\n
3400
3401 /((?m)^b$)/
3402     a\nb\nc\n
3403
3404 /(?m)^b/
3405     a\nb\n
3406
3407 /(?m)^(b)/
3408     a\nb\n
3409
3410 /((?m)^b)/
3411     a\nb\n
3412
3413 /\n((?m)^b)/
3414     a\nb\n
3415
3416 /((?s).)c(?!.)/
3417     a\nb\nc\n
3418     a\nb\nc\n
3419
3420 /((?s)b.)c(?!.)/
3421     a\nb\nc\n
3422     a\nb\nc\n
3423
3424 /^b/
3425
3426 /()^b/
3427     *** Failers
3428     a\nb\nc\n
3429     a\nb\nc\n
3430
3431 /((?m)^b)/
3432     a\nb\nc\n
3433
3434 /(x)?(?(1)a|b)/
3435     *** Failers
3436     a
3437     a
3438
3439 /(x)?(?(1)b|a)/
3440     a
3441
3442 /()?(?(1)b|a)/
3443     a
3444
3445 /()(?(1)b|a)/
3446
3447 /()?(?(1)a|b)/
3448     a
3449
3450 /^(\()?blah(?(1)(\)))$/
3451     (blah)
3452     blah
3453     *** Failers
3454     a
3455     blah)
3456     (blah
3457
3458 /^(\(+)?blah(?(1)(\)))$/
3459     (blah)
3460     blah
3461     *** Failers
3462     blah)
3463     (blah
3464
3465 /(?(?!a)a|b)/
3466
3467 /(?(?!a)b|a)/
3468     a
3469
3470 /(?(?=a)b|a)/
3471     *** Failers
3472     a
3473     a
3474
3475 /(?(?=a)a|b)/
3476     a
3477
3478 /(?=(a+?))(\1ab)/
3479     aaab
3480
3481 /^(?=(a+?))\1ab/
3482
3483 /(\w+:)+/
3484     one:
3485
3486 /$(?<=^(a))/
3487     a
3488
3489 /(?=(a+?))(\1ab)/
3490     aaab
3491
3492 /^(?=(a+?))\1ab/
3493     *** Failers
3494     aaab
3495     aaab
3496
3497 /([\w:]+::)?(\w+)$/
3498     abcd
3499     xy:z:::abcd
3500
3501 /^[^bcd]*(c+)/
3502     aexycd
3503
3504 /(a*)b+/
3505     caab
3506
3507 /([\w:]+::)?(\w+)$/
3508     abcd
3509     xy:z:::abcd
3510     *** Failers
3511     abcd:
3512     abcd:
3513
3514 /^[^bcd]*(c+)/
3515     aexycd
3516
3517 /(>a+)ab/
3518
3519 /(?>a+)b/
3520     aaab
3521
3522 /([[:]+)/
3523     a:[b]:
3524
3525 /([[=]+)/
3526     a=[b]=
3527
3528 /([[.]+)/
3529     a.[b].
3530
3531 /((?>a+)b)/
3532     aaab
3533
3534 /(?>(a+))b/
3535     aaab
3536
3537 /((?>[^()]+)|\([^()]*\))+/
3538     ((abc(ade)ufh()()x
3539
3540 /a\Z/
3541     *** Failers
3542     aaab
3543     a\nb\n
3544
3545 /b\Z/
3546     a\nb\n
3547
3548 /b\z/
3549
3550 /b\Z/
3551     a\nb
3552
3553 /b\z/
3554     a\nb
3555     *** Failers
3556     
3557 /^(?>(?(1)\.|())[^\W_](?>[a-z0-9-]*[^\W_])?)+$/
3558     a
3559     abc
3560     a-b
3561     0-9 
3562     a.b
3563     5.6.7  
3564     the.quick.brown.fox
3565     a100.b200.300c  
3566     12-ab.1245 
3567     *** Failers
3568     \
3569     .a
3570     -a
3571     a-
3572     a.  
3573     a_b 
3574     a.-
3575     a..  
3576     ab..bc 
3577     the.quick.brown.fox-
3578     the.quick.brown.fox.
3579     the.quick.brown.fox_
3580     the.quick.brown.fox+       
3581
3582 /(?>.*)(?<=(abcd|wxyz))/
3583     alphabetabcd
3584     endingwxyz
3585     *** Failers
3586     a rather long string that doesn't end with one of them
3587
3588 /word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
3589     word cat dog elephant mussel cow horse canary baboon snake shark otherword
3590     word cat dog elephant mussel cow horse canary baboon snake shark
3591   
3592 /word (?>[a-zA-Z0-9]+ ){0,30}otherword/
3593     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
3594
3595 /(?<=\d{3}(?!999))foo/
3596     999foo
3597     123999foo 
3598     *** Failers
3599     123abcfoo
3600     
3601 /(?<=(?!...999)\d{3})foo/
3602     999foo
3603     123999foo 
3604     *** Failers
3605     123abcfoo
3606
3607 /(?<=\d{3}(?!999)...)foo/
3608     123abcfoo
3609     123456foo 
3610     *** Failers
3611     123999foo  
3612     
3613 /(?<=\d{3}...)(?<!999)foo/
3614     123abcfoo   
3615     123456foo 
3616     *** Failers
3617     123999foo  
3618
3619 /<a[\s]+href[\s]*=[\s]*          # find <a href=
3620  ([\"\'])?                       # find single or double quote
3621  (?(1) (.*?)\1 | ([^\s]+))       # if quote found, match up to next matching
3622                                  # quote, otherwise match up to next space
3623 /isx
3624     <a href=abcd xyz
3625     <a href=\"abcd xyz pqr\" cats
3626     <a href=\'abcd xyz pqr\' cats
3627
3628 /<a\s+href\s*=\s*                # find <a href=
3629  (["'])?                         # find single or double quote
3630  (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
3631                                  # quote, otherwise match up to next space
3632 /isx
3633     <a href=abcd xyz
3634     <a href=\"abcd xyz pqr\" cats
3635     <a href       =       \'abcd xyz pqr\' cats
3636
3637 /<a\s+href(?>\s*)=(?>\s*)        # find <a href=
3638  (["'])?                         # find single or double quote
3639  (?(1) (.*?)\1 | (\S+))          # if quote found, match up to next matching
3640                                  # quote, otherwise match up to next space
3641 /isx
3642     <a href=abcd xyz
3643     <a href=\"abcd xyz pqr\" cats
3644     <a href       =       \'abcd xyz pqr\' cats
3645
3646 /((Z)+|A)*/
3647     ZABCDEFG
3648
3649 /(Z()|A)*/
3650     ZABCDEFG
3651
3652 /(Z(())|A)*/
3653     ZABCDEFG
3654
3655 /((?>Z)+|A)*/
3656     ZABCDEFG
3657
3658 /((?>)+|A)*/
3659     ZABCDEFG
3660
3661 /a*/g
3662     abbab
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]