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.

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