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