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