github的一些开源项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10506 lines
163 KiB

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