blob: 0ca0d23c4dba218a16a784ea2f415dcffe9063cb [file] [log] [blame]
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001# This set of tests check the DFA matching functionality of pcre2_dfa_match(),
2# excluding UTF and Unicode property support. All matches are done using DFA,
3# forced by setting a default subject modifier at the start.
Nick Kralevichf73ff172014-09-27 12:41:49 -07004
Janis Danisevskis53e448c2016-03-31 13:35:25 +01005#forbid_utf
6#subject dfa
7#newline_default lf anycrlf any
Nick Kralevichf73ff172014-09-27 12:41:49 -07008
9/abc/
10 abc
11
12/ab*c/
13 abc
14 abbbbc
15 ac
16
17/ab+c/
18 abc
19 abbbbbbc
Janis Danisevskis53e448c2016-03-31 13:35:25 +010020\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070021 ac
22 ab
23
Janis Danisevskis53e448c2016-03-31 13:35:25 +010024/a*/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -070025 a
26 aaaaaaaaaaaaaaaaa
Janis Danisevskis53e448c2016-03-31 13:35:25 +010027 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\=ovector=10
28 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\=dfa_shortest
Nick Kralevichf73ff172014-09-27 12:41:49 -070029
30/(a|abcd|african)/
31 a
32 abcd
33 african
34
35/^abc/
36 abcdef
Janis Danisevskis53e448c2016-03-31 13:35:25 +010037\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070038 xyzabc
39 xyz\nabc
40
41/^abc/m
42 abcdef
43 xyz\nabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +010044\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070045 xyzabc
46
47/\Aabc/
48 abcdef
Janis Danisevskis53e448c2016-03-31 13:35:25 +010049\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070050 xyzabc
51 xyz\nabc
52
53/\Aabc/m
54 abcdef
Janis Danisevskis53e448c2016-03-31 13:35:25 +010055\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070056 xyzabc
57 xyz\nabc
58
59/\Gabc/
60 abcdef
Janis Danisevskis53e448c2016-03-31 13:35:25 +010061 xyzabc\=offset=3
62\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070063 xyzabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +010064 xyzabc\=offset=2
Nick Kralevichf73ff172014-09-27 12:41:49 -070065
66/x\dy\Dz/
67 x9yzz
68 x0y+z
Janis Danisevskis53e448c2016-03-31 13:35:25 +010069\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070070 xyz
71 xxy0z
72
73/x\sy\Sz/
74 x yzz
75 x y+z
Janis Danisevskis53e448c2016-03-31 13:35:25 +010076\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070077 xyz
78 xxyyz
79
80/x\wy\Wz/
81 xxy+z
Janis Danisevskis53e448c2016-03-31 13:35:25 +010082\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070083 xxy0z
84 x+y+z
85
86/x.y/
87 x+y
88 x-y
Janis Danisevskis53e448c2016-03-31 13:35:25 +010089\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -070090 x\ny
91
92/x.y/s
93 x+y
94 x-y
95 x\ny
96
97/(a.b(?s)c.d|x.y)p.q/
98 a+bc+dp+q
99 a+bc\ndp+q
100 x\nyp+q
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100101\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700102 a\nbc\ndp+q
103 a+bc\ndp\nq
104 x\nyp\nq
105
106/a\d\z/
107 ba0
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100108\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700109 ba0\n
110 ba0\ncd
111
112/a\d\z/m
113 ba0
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100114\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700115 ba0\n
116 ba0\ncd
117
118/a\d\Z/
119 ba0
120 ba0\n
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100121\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700122 ba0\ncd
123
124/a\d\Z/m
125 ba0
126 ba0\n
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100127\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700128 ba0\ncd
129
130/a\d$/
131 ba0
132 ba0\n
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100133\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700134 ba0\ncd
135
136/a\d$/m
137 ba0
138 ba0\n
139 ba0\ncd
Nick Kralevichf73ff172014-09-27 12:41:49 -0700140
141/abc/i
142 abc
143 aBc
144 ABC
145
146/[^a]/
147 abcd
148
149/ab?\w/
150 abz
151 abbz
152 azz
153
154/x{0,3}yz/
155 ayzq
156 axyzq
157 axxyz
158 axxxyzq
159 axxxxyzq
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100160\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700161 ax
162 axx
163
164/x{3}yz/
165 axxxyzq
166 axxxxyzq
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100167\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700168 ax
169 axx
170 ayzq
171 axyzq
172 axxyz
173
174/x{2,3}yz/
175 axxyz
176 axxxyzq
177 axxxxyzq
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100178\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700179 ax
180 axx
181 ayzq
182 axyzq
183
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100184/[^a]+/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -0700185 bac
186 bcdefax
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100187\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700188 aaaaa
189
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100190/[^a]*/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -0700191 bac
192 bcdefax
Nick Kralevichf73ff172014-09-27 12:41:49 -0700193 aaaaa
194
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100195/[^a]{3,5}/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -0700196 xyz
197 awxyza
198 abcdefa
199 abcdefghijk
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100200\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700201 axya
202 axa
203 aaaaa
204
205/\d*/
206 1234b567
207 xyz
208
209/\D*/
210 a1234b567
211 xyz
212
213/\d+/
214 ab1234c56
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100215\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700216 xyz
217
218/\D+/
219 ab123c56
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100220\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700221 789
222
223/\d?A/
224 045ABC
225 ABC
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100226\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700227 XYZ
228
229/\D?A/
230 ABC
231 BAC
232 9ABC
Nick Kralevichf73ff172014-09-27 12:41:49 -0700233
234/a+/
235 aaaa
236
237/^.*xyz/
238 xyz
239 ggggggggxyz
240
241/^.+xyz/
242 abcdxyz
243 axyz
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100244\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700245 xyz
246
247/^.?xyz/
248 xyz
249 cxyz
250
251/^\d{2,3}X/
252 12X
253 123X
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100254\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700255 X
256 1X
257 1234X
258
259/^[abcd]\d/
260 a45
261 b93
262 c99z
263 d04
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100264\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700265 e45
266 abcd
267 abcd1234
268 1234
269
270/^[abcd]*\d/
271 a45
272 b93
273 c99z
274 d04
275 abcd1234
276 1234
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100277\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700278 e45
279 abcd
280
281/^[abcd]+\d/
282 a45
283 b93
284 c99z
285 d04
286 abcd1234
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100287\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700288 1234
289 e45
290 abcd
291
292/^a+X/
293 aX
294 aaX
295
296/^[abcd]?\d/
297 a45
298 b93
299 c99z
300 d04
301 1234
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100302\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700303 abcd1234
304 e45
305
306/^[abcd]{2,3}\d/
307 ab45
308 bcd93
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100309\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700310 1234
311 a36
312 abcd1234
313 ee45
314
315/^(abc)*\d/
316 abc45
317 abcabcabc45
318 42xyz
Nick Kralevichf73ff172014-09-27 12:41:49 -0700319
320/^(abc)+\d/
321 abc45
322 abcabcabc45
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100323\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700324 42xyz
325
326/^(abc)?\d/
327 abc45
328 42xyz
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100329\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700330 abcabcabc45
331
332/^(abc){2,3}\d/
333 abcabc45
334 abcabcabc45
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100335\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700336 abcabcabcabc45
337 abc45
338 42xyz
339
340/1(abc|xyz)2(?1)3/
341 1abc2abc3456
342 1abc2xyz3456
343
344/^(a*\w|ab)=(a*\w|ab)/
345 ab=ab
346
347/^(a*\w|ab)=(?1)/
348 ab=ab
349
350/^([^()]|\((?1)*\))*$/
351 abc
352 a(b)c
353 a(b(c))d
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100354\= Expect no match)
Nick Kralevichf73ff172014-09-27 12:41:49 -0700355 a(b(c)d
356
357/^>abc>([^()]|\((?1)*\))*<xyz<$/
358 >abc>123<xyz<
359 >abc>1(2)3<xyz<
360 >abc>(1(2)3)<xyz<
361
362/^(?>a*)\d/
363 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa9876
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100364\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700365 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
366
367/< (?: (?(R) \d++ | [^<>]*+) | (?R)) * >/x
368 <>
369 <abcd>
370 <abc <123> hij>
371 <abc <def> hij>
372 <abc<>def>
373 <abc<>
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100374\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700375 <abc
376
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100377/^(?(?=abc)\w{3}:|\d\d)$/
Nick Kralevichf73ff172014-09-27 12:41:49 -0700378 abc:
379 12
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100380\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700381 123
382 xyz
383
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100384/^(?(?!abc)\d\d|\w{3}:)$/
Nick Kralevichf73ff172014-09-27 12:41:49 -0700385 abc:
386 12
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100387\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700388 123
389 xyz
390
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100391/^(?=abc)\w{5}:$/
Nick Kralevichf73ff172014-09-27 12:41:49 -0700392 abcde:
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100393\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700394 abc..
395 123
396 vwxyz
397
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100398/^(?!abc)\d\d$/
Nick Kralevichf73ff172014-09-27 12:41:49 -0700399 12
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100400\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700401 abcde:
402 abc..
403 123
404 vwxyz
405
406/(?<=abc|xy)123/
407 abc12345
408 wxy123z
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100409\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700410 123abc
411
412/(?<!abc|xy)123/
413 123abc
414 mno123456
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100415\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700416 abc12345
417 wxy123z
418
419/abc(?C1)xyz/
420 abcxyz
421 123abcxyz999
422
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100423/(ab|cd){3,4}/auto_callout
Nick Kralevichf73ff172014-09-27 12:41:49 -0700424 ababab
425 abcdabcd
426 abcdcdcdcdcd
427
428/^abc/
429 abcdef
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100430\= Expect no match
431 abcdef\=notbol
Nick Kralevichf73ff172014-09-27 12:41:49 -0700432
433/^(a*|xyz)/
434 bcd
435 aaabcd
436 xyz
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100437 xyz\=notempty
438\= Expect no match
439 bcd\=notempty
Nick Kralevichf73ff172014-09-27 12:41:49 -0700440
441/xyz$/
442 xyz
443 xyz\n
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100444\= Expect no match
445 xyz\=noteol
446 xyz\n\=noteol
Nick Kralevichf73ff172014-09-27 12:41:49 -0700447
448/xyz$/m
449 xyz
450 xyz\n
451 abcxyz\npqr
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100452 abcxyz\npqr\=noteol
453 xyz\n\=noteol
454\= Expect no match
455 xyz\=noteol
Nick Kralevichf73ff172014-09-27 12:41:49 -0700456
457/\Gabc/
458 abcdef
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100459 defabcxyz\=offset=3
460\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700461 defabcxyz
462
463/^abcdef/
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100464 ab\=ps
465 abcde\=ps
466 abcdef\=ps
467\= Expect no match
468 abx\=ps
Nick Kralevichf73ff172014-09-27 12:41:49 -0700469
470/^a{2,4}\d+z/
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100471 a\=ps
472 aa\=ps
473 aa2\=ps
474 aaa\=ps
475 aaa23\=ps
476 aaaa12345\=ps
477 aa0z\=ps
478 aaaa4444444444444z\=ps
479\= Expect no match
480 az\=ps
481 aaaaa\=ps
482 a56\=ps
Nick Kralevichf73ff172014-09-27 12:41:49 -0700483
484/^abcdef/
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100485 abc\=ps
486 def\=dfa_restart
Nick Kralevichf73ff172014-09-27 12:41:49 -0700487
488/(?<=foo)bar/
Elliott Hughes2dbd7d22020-06-03 14:32:37 -0700489 foob\=ps,offset=2,allusedtext
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100490 foobar...\=ps,dfa_restart,offset=4
491 foobar\=offset=2
492\= Expect no match
493 xyzfo\=ps
494 obar\=dfa_restart
Nick Kralevichf73ff172014-09-27 12:41:49 -0700495
496/(ab*(cd|ef))+X/
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100497 lkjhlkjhlkjhlkjhabbbbbbcdaefabbbbbbbefa\=ps,notbol,noteol
498 cdabbbbbbbb\=ps,notbol,dfa_restart,noteol
499 efabbbbbbbbbbbbbbbb\=ps,notbol,dfa_restart,noteol
500 bbbbbbbbbbbbcdXyasdfadf\=ps,notbol,dfa_restart,noteol
501\= Expect no match
502 adfadadaklhlkalkajhlkjahdfasdfasdfladsfjkj\=ps,noteol
Nick Kralevichf73ff172014-09-27 12:41:49 -0700503
Nick Kralevichf73ff172014-09-27 12:41:49 -0700504/the quick brown fox/
505 the quick brown fox
Nick Kralevichf73ff172014-09-27 12:41:49 -0700506 What do you know about the quick brown fox?
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100507\= Expect no match
508 The quick brown FOX
Nick Kralevichf73ff172014-09-27 12:41:49 -0700509 What do you know about THE QUICK BROWN FOX?
510
511/The quick brown fox/i
512 the quick brown fox
513 The quick brown FOX
514 What do you know about the quick brown fox?
515 What do you know about THE QUICK BROWN FOX?
516
517/abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz/
518 abcd\t\n\r\f\a\e9;\$\\?caxyz
519
520/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/
521 abxyzpqrrrabbxyyyypqAzz
522 abxyzpqrrrabbxyyyypqAzz
523 aabxyzpqrrrabbxyyyypqAzz
524 aaabxyzpqrrrabbxyyyypqAzz
525 aaaabxyzpqrrrabbxyyyypqAzz
526 abcxyzpqrrrabbxyyyypqAzz
527 aabcxyzpqrrrabbxyyyypqAzz
528 aaabcxyzpqrrrabbxyyyypAzz
529 aaabcxyzpqrrrabbxyyyypqAzz
530 aaabcxyzpqrrrabbxyyyypqqAzz
531 aaabcxyzpqrrrabbxyyyypqqqAzz
532 aaabcxyzpqrrrabbxyyyypqqqqAzz
533 aaabcxyzpqrrrabbxyyyypqqqqqAzz
534 aaabcxyzpqrrrabbxyyyypqqqqqqAzz
535 aaaabcxyzpqrrrabbxyyyypqAzz
536 abxyzzpqrrrabbxyyyypqAzz
537 aabxyzzzpqrrrabbxyyyypqAzz
538 aaabxyzzzzpqrrrabbxyyyypqAzz
539 aaaabxyzzzzpqrrrabbxyyyypqAzz
540 abcxyzzpqrrrabbxyyyypqAzz
541 aabcxyzzzpqrrrabbxyyyypqAzz
542 aaabcxyzzzzpqrrrabbxyyyypqAzz
543 aaaabcxyzzzzpqrrrabbxyyyypqAzz
544 aaaabcxyzzzzpqrrrabbbxyyyypqAzz
545 aaaabcxyzzzzpqrrrabbbxyyyyypqAzz
546 aaabcxyzpqrrrabbxyyyypABzz
547 aaabcxyzpqrrrabbxyyyypABBzz
548 >>>aaabxyzpqrrrabbxyyyypqAzz
549 >aaaabxyzpqrrrabbxyyyypqAzz
550 >>>>abcxyzpqrrrabbxyyyypqAzz
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100551\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700552 abxyzpqrrabbxyyyypqAzz
553 abxyzpqrrrrabbxyyyypqAzz
554 abxyzpqrrrabxyyyypqAzz
555 aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz
556 aaaabcxyzzzzpqrrrabbbxyyypqAzz
557 aaabcxyzpqrrrabbxyyyypqqqqqqqAzz
558
559/^(abc){1,2}zz/
560 abczz
561 abcabczz
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100562\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700563 zz
564 abcabcabczz
565 >>abczz
566
567/^(b+?|a){1,2}?c/
568 bc
569 bbc
570 bbbc
571 bac
572 bbac
573 aac
574 abbbbbbbbbbbc
575 bbbbbbbbbbbac
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100576\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700577 aaac
578 abbbbbbbbbbbac
579
580/^(b+|a){1,2}c/
581 bc
582 bbc
583 bbbc
584 bac
585 bbac
586 aac
587 abbbbbbbbbbbc
588 bbbbbbbbbbbac
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100589\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700590 aaac
591 abbbbbbbbbbbac
592
593/^(b+|a){1,2}?bc/
594 bbc
595
596/^(b*|ba){1,2}?bc/
597 babc
598 bbabc
599 bababc
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100600\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700601 bababbc
602 babababc
603
604/^(ba|b*){1,2}?bc/
605 babc
606 bbabc
607 bababc
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100608\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700609 bababbc
610 babababc
611
612/^\ca\cA\c[\c{\c:/
613 \x01\x01\e;z
614
615/^[ab\]cde]/
616 athing
617 bthing
618 ]thing
619 cthing
620 dthing
621 ething
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100622\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700623 fthing
624 [thing
625 \\thing
626
627/^[]cde]/
628 ]thing
629 cthing
630 dthing
631 ething
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100632\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700633 athing
634 fthing
635
636/^[^ab\]cde]/
637 fthing
638 [thing
639 \\thing
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100640\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700641 athing
642 bthing
643 ]thing
644 cthing
645 dthing
646 ething
647
648/^[^]cde]/
649 athing
650 fthing
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100651\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700652 ]thing
653 cthing
654 dthing
655 ething
656
657/^\/
658 
659
660/^ÿ/
661 ÿ
662
663/^[0-9]+$/
664 0
665 1
666 2
667 3
668 4
669 5
670 6
671 7
672 8
673 9
674 10
675 100
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100676\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700677 abc
678
679/^.*nter/
680 enter
681 inter
682 uponter
683
684/^xxx[0-9]+$/
685 xxx0
686 xxx1234
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100687\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700688 xxx
689
690/^.+[0-9][0-9][0-9]$/
691 x123
692 xx123
693 123456
Nick Kralevichf73ff172014-09-27 12:41:49 -0700694 x1234
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100695\= Expect no match
696 123
Nick Kralevichf73ff172014-09-27 12:41:49 -0700697
698/^.+?[0-9][0-9][0-9]$/
699 x123
700 xx123
701 123456
Nick Kralevichf73ff172014-09-27 12:41:49 -0700702 x1234
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100703\= Expect no match
704 123
Nick Kralevichf73ff172014-09-27 12:41:49 -0700705
706/^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$/
707 abc!pqr=apquxz.ixr.zzz.ac.uk
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100708\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700709 !pqr=apquxz.ixr.zzz.ac.uk
710 abc!=apquxz.ixr.zzz.ac.uk
711 abc!pqr=apquxz:ixr.zzz.ac.uk
712 abc!pqr=apquxz.ixr.zzz.ac.ukk
713
714/:/
715 Well, we need a colon: somewhere
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100716\= Expect no match
717 No match without a colon
Nick Kralevichf73ff172014-09-27 12:41:49 -0700718
719/([\da-f:]+)$/i
720 0abc
721 abc
722 fed
723 E
724 ::
725 5f03:12C0::932e
726 fed def
727 Any old stuff
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100728\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700729 0zzz
730 gzzz
731 fed\x20
732 Any old rubbish
733
734/^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
735 .1.2.3
736 A.12.123.0
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100737\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700738 .1.2.3333
739 1.2.3
740 1234.2.3
741
742/^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$/
743 1 IN SOA non-sp1 non-sp2(
744 1 IN SOA non-sp1 non-sp2 (
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100745\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700746 1IN SOA non-sp1 non-sp2(
747
748/^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$/
749 a.
750 Z.
751 2.
752 ab-c.pq-r.
753 sxk.zzz.ac.uk.
754 x-.y-.
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100755\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700756 -abc.peq.
757
758/^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$/
759 *.a
760 *.b0-a
761 *.c3-b.c
762 *.c-a.b-c
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100763\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700764 *.0
765 *.a-
766 *.a-b.c-
767 *.c-a.0-c
768
769/^(?=ab(de))(abd)(e)/
770 abde
771
772/^(?!(ab)de|x)(abd)(f)/
773 abdf
774
775/^(?=(ab(cd)))(ab)/
776 abcd
777
778/^[\da-f](\.[\da-f])*$/i
779 a.b.c.d
780 A.B.C.D
781 a.b.c.1.2.3.C
782
783/^\".*\"\s*(;.*)?$/
784 \"1234\"
785 \"abcd\" ;
786 \"\" ; rhubarb
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100787\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700788 \"1234\" : things
789
790/^$/
791 \
Nick Kralevichf73ff172014-09-27 12:41:49 -0700792
793/ ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/x
794 ab c
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100795\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700796 abc
797 ab cde
798
799/(?x) ^ a (?# begins with a) b\sc (?# then b c) $ (?# then end)/
800 ab c
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100801\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700802 abc
803 ab cde
804
805/^ a\ b[c ]d $/x
806 a bcd
807 a b d
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100808\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700809 abcd
810 ab d
811
812/^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$/
813 abcdefhijklm
814
815/^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$/
816 abcdefhijklm
817
818/^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]/
819 a+ Z0+\x08\n\x1d\x12
820
821/^[.^$|()*+?{,}]+/
822 .^\$(*+)|{?,?}
823
824/^a*\w/
825 z
826 az
827 aaaz
828 a
829 aa
830 aaaa
831 a+
832 aa+
833
834/^a*?\w/
835 z
836 az
837 aaaz
838 a
839 aa
840 aaaa
841 a+
842 aa+
843
844/^a+\w/
845 az
846 aaaz
847 aa
848 aaaa
849 aa+
850
851/^a+?\w/
852 az
853 aaaz
854 aa
855 aaaa
856 aa+
857
858/^\d{8}\w{2,}/
859 1234567890
860 12345678ab
861 12345678__
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100862\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700863 1234567
864
865/^[aeiou\d]{4,5}$/
866 uoie
867 1234
868 12345
869 aaaaa
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100870\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700871 123456
872
873/^[aeiou\d]{4,5}?/
874 uoie
875 1234
876 12345
877 aaaaa
878 123456
879
880/^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]/
881 From abcd Mon Sep 01 12:33:02 1997
882
883/^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d/
884 From abcd Mon Sep 01 12:33:02 1997
885 From abcd Mon Sep 1 12:33:02 1997
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100886\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700887 From abcd Sep 01 12:33:02 1997
888
889/^12.34/s
890 12\n34
891 12\r34
892
893/\w+(?=\t)/
894 the quick brown\t fox
895
896/foo(?!bar)(.*)/
897 foobar is foolish see?
898
899/(?:(?!foo)...|^.{0,2})bar(.*)/
900 foobar crowbar etc
901 barrel
902 2barrel
903 A barrel
904
905/^(\D*)(?=\d)(?!123)/
906 abc456
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100907\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700908 abc123
909
910/^1234(?# test newlines
911 inside)/
912 1234
913
914/^1234 #comment in extended re
915 /x
916 1234
917
918/#rhubarb
919 abcd/x
920 abcd
921
922/^abcd#rhubarb/x
923 abcd
924
925/(?!^)abc/
926 the abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100927\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700928 abc
929
930/(?=^)abc/
931 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100932\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -0700933 the abc
934
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100935/^[ab]{1,3}(ab*|b)/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -0700936 aabbbbb
937
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100938/^[ab]{1,3}?(ab*|b)/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -0700939 aabbbbb
940
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100941/^[ab]{1,3}?(ab*?|b)/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -0700942 aabbbbb
943
Janis Danisevskis53e448c2016-03-31 13:35:25 +0100944/^[ab]{1,3}(ab*?|b)/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -0700945 aabbbbb
946
947/ (?: [\040\t] | \(
948(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
949\) )* # optional leading comment
950(?: (?:
951[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
952(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
953|
954" (?: # opening quote...
955[^\\\x80-\xff\n\015"] # Anything except backslash and quote
956| # or
957\\ [^\x80-\xff] # Escaped something (something != CR)
958)* " # closing quote
959) # initial word
960(?: (?: [\040\t] | \(
961(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
962\) )* \. (?: [\040\t] | \(
963(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
964\) )* (?:
965[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
966(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
967|
968" (?: # opening quote...
969[^\\\x80-\xff\n\015"] # Anything except backslash and quote
970| # or
971\\ [^\x80-\xff] # Escaped something (something != CR)
972)* " # closing quote
973) )* # further okay, if led by a period
974(?: [\040\t] | \(
975(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
976\) )* @ (?: [\040\t] | \(
977(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
978\) )* (?:
979[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
980(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
981| \[ # [
982(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
983\] # ]
984) # initial subdomain
985(?: #
986(?: [\040\t] | \(
987(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
988\) )* \. # if led by a period...
989(?: [\040\t] | \(
990(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
991\) )* (?:
992[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
993(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
994| \[ # [
995(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
996\] # ]
997) # ...further okay
998)*
999# address
1000| # or
1001(?:
1002[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1003(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1004|
1005" (?: # opening quote...
1006[^\\\x80-\xff\n\015"] # Anything except backslash and quote
1007| # or
1008\\ [^\x80-\xff] # Escaped something (something != CR)
1009)* " # closing quote
1010) # one word, optionally followed by....
1011(?:
1012[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] | # atom and space parts, or...
1013\(
1014(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1015\) | # comments, or...
1016
1017" (?: # opening quote...
1018[^\\\x80-\xff\n\015"] # Anything except backslash and quote
1019| # or
1020\\ [^\x80-\xff] # Escaped something (something != CR)
1021)* " # closing quote
1022# quoted strings
1023)*
1024< (?: [\040\t] | \(
1025(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1026\) )* # leading <
1027(?: @ (?: [\040\t] | \(
1028(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1029\) )* (?:
1030[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1031(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1032| \[ # [
1033(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1034\] # ]
1035) # initial subdomain
1036(?: #
1037(?: [\040\t] | \(
1038(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1039\) )* \. # if led by a period...
1040(?: [\040\t] | \(
1041(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1042\) )* (?:
1043[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1044(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1045| \[ # [
1046(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1047\] # ]
1048) # ...further okay
1049)*
1050
1051(?: (?: [\040\t] | \(
1052(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1053\) )* , (?: [\040\t] | \(
1054(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1055\) )* @ (?: [\040\t] | \(
1056(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1057\) )* (?:
1058[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1059(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1060| \[ # [
1061(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1062\] # ]
1063) # initial subdomain
1064(?: #
1065(?: [\040\t] | \(
1066(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1067\) )* \. # if led by a period...
1068(?: [\040\t] | \(
1069(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1070\) )* (?:
1071[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1072(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1073| \[ # [
1074(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1075\] # ]
1076) # ...further okay
1077)*
1078)* # further okay, if led by comma
1079: # closing colon
1080(?: [\040\t] | \(
1081(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1082\) )* )? # optional route
1083(?:
1084[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1085(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1086|
1087" (?: # opening quote...
1088[^\\\x80-\xff\n\015"] # Anything except backslash and quote
1089| # or
1090\\ [^\x80-\xff] # Escaped something (something != CR)
1091)* " # closing quote
1092) # initial word
1093(?: (?: [\040\t] | \(
1094(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1095\) )* \. (?: [\040\t] | \(
1096(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1097\) )* (?:
1098[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1099(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1100|
1101" (?: # opening quote...
1102[^\\\x80-\xff\n\015"] # Anything except backslash and quote
1103| # or
1104\\ [^\x80-\xff] # Escaped something (something != CR)
1105)* " # closing quote
1106) )* # further okay, if led by a period
1107(?: [\040\t] | \(
1108(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1109\) )* @ (?: [\040\t] | \(
1110(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1111\) )* (?:
1112[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1113(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1114| \[ # [
1115(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1116\] # ]
1117) # initial subdomain
1118(?: #
1119(?: [\040\t] | \(
1120(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1121\) )* \. # if led by a period...
1122(?: [\040\t] | \(
1123(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1124\) )* (?:
1125[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1126(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1127| \[ # [
1128(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1129\] # ]
1130) # ...further okay
1131)*
1132# address spec
1133(?: [\040\t] | \(
1134(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1135\) )* > # trailing >
1136# name and address
1137) (?: [\040\t] | \(
1138(?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] | \( (?: [^\\\x80-\xff\n\015()] | \\ [^\x80-\xff] )* \) )*
1139\) )* # optional trailing comment
1140/x
1141 Alan Other <user\@dom.ain>
1142 <user\@dom.ain>
1143 user\@dom.ain
1144 \"A. Other\" <user.1234\@dom.ain> (a comment)
1145 A. Other <user.1234\@dom.ain> (a comment)
1146 \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
1147 A missing angle <user\@some.where
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001148\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001149 The quick brown fox
1150
1151/[\040\t]* # Nab whitespace.
1152(?:
1153\( # (
1154[^\\\x80-\xff\n\015()] * # normal*
1155(?: # (
1156(?: \\ [^\x80-\xff] |
1157\( # (
1158[^\\\x80-\xff\n\015()] * # normal*
1159(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1160\) # )
1161) # special
1162[^\\\x80-\xff\n\015()] * # normal*
1163)* # )*
1164\) # )
1165[\040\t]* )* # If comment found, allow more spaces.
1166# optional leading comment
1167(?:
1168(?:
1169[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1170(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1171# Atom
1172| # or
1173" # "
1174[^\\\x80-\xff\n\015"] * # normal
1175(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
1176" # "
1177# Quoted string
1178)
1179[\040\t]* # Nab whitespace.
1180(?:
1181\( # (
1182[^\\\x80-\xff\n\015()] * # normal*
1183(?: # (
1184(?: \\ [^\x80-\xff] |
1185\( # (
1186[^\\\x80-\xff\n\015()] * # normal*
1187(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1188\) # )
1189) # special
1190[^\\\x80-\xff\n\015()] * # normal*
1191)* # )*
1192\) # )
1193[\040\t]* )* # If comment found, allow more spaces.
1194(?:
1195\.
1196[\040\t]* # Nab whitespace.
1197(?:
1198\( # (
1199[^\\\x80-\xff\n\015()] * # normal*
1200(?: # (
1201(?: \\ [^\x80-\xff] |
1202\( # (
1203[^\\\x80-\xff\n\015()] * # normal*
1204(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1205\) # )
1206) # special
1207[^\\\x80-\xff\n\015()] * # normal*
1208)* # )*
1209\) # )
1210[\040\t]* )* # If comment found, allow more spaces.
1211(?:
1212[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1213(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1214# Atom
1215| # or
1216" # "
1217[^\\\x80-\xff\n\015"] * # normal
1218(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
1219" # "
1220# Quoted string
1221)
1222[\040\t]* # Nab whitespace.
1223(?:
1224\( # (
1225[^\\\x80-\xff\n\015()] * # normal*
1226(?: # (
1227(?: \\ [^\x80-\xff] |
1228\( # (
1229[^\\\x80-\xff\n\015()] * # normal*
1230(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1231\) # )
1232) # special
1233[^\\\x80-\xff\n\015()] * # normal*
1234)* # )*
1235\) # )
1236[\040\t]* )* # If comment found, allow more spaces.
1237# additional words
1238)*
1239@
1240[\040\t]* # Nab whitespace.
1241(?:
1242\( # (
1243[^\\\x80-\xff\n\015()] * # normal*
1244(?: # (
1245(?: \\ [^\x80-\xff] |
1246\( # (
1247[^\\\x80-\xff\n\015()] * # normal*
1248(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1249\) # )
1250) # special
1251[^\\\x80-\xff\n\015()] * # normal*
1252)* # )*
1253\) # )
1254[\040\t]* )* # If comment found, allow more spaces.
1255(?:
1256[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1257(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1258|
1259\[ # [
1260(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1261\] # ]
1262)
1263[\040\t]* # Nab whitespace.
1264(?:
1265\( # (
1266[^\\\x80-\xff\n\015()] * # normal*
1267(?: # (
1268(?: \\ [^\x80-\xff] |
1269\( # (
1270[^\\\x80-\xff\n\015()] * # normal*
1271(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1272\) # )
1273) # special
1274[^\\\x80-\xff\n\015()] * # normal*
1275)* # )*
1276\) # )
1277[\040\t]* )* # If comment found, allow more spaces.
1278# optional trailing comments
1279(?:
1280\.
1281[\040\t]* # Nab whitespace.
1282(?:
1283\( # (
1284[^\\\x80-\xff\n\015()] * # normal*
1285(?: # (
1286(?: \\ [^\x80-\xff] |
1287\( # (
1288[^\\\x80-\xff\n\015()] * # normal*
1289(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1290\) # )
1291) # special
1292[^\\\x80-\xff\n\015()] * # normal*
1293)* # )*
1294\) # )
1295[\040\t]* )* # If comment found, allow more spaces.
1296(?:
1297[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1298(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1299|
1300\[ # [
1301(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1302\] # ]
1303)
1304[\040\t]* # Nab whitespace.
1305(?:
1306\( # (
1307[^\\\x80-\xff\n\015()] * # normal*
1308(?: # (
1309(?: \\ [^\x80-\xff] |
1310\( # (
1311[^\\\x80-\xff\n\015()] * # normal*
1312(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1313\) # )
1314) # special
1315[^\\\x80-\xff\n\015()] * # normal*
1316)* # )*
1317\) # )
1318[\040\t]* )* # If comment found, allow more spaces.
1319# optional trailing comments
1320)*
1321# address
1322| # or
1323(?:
1324[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1325(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1326# Atom
1327| # or
1328" # "
1329[^\\\x80-\xff\n\015"] * # normal
1330(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
1331" # "
1332# Quoted string
1333)
1334# leading word
1335[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # "normal" atoms and or spaces
1336(?:
1337(?:
1338\( # (
1339[^\\\x80-\xff\n\015()] * # normal*
1340(?: # (
1341(?: \\ [^\x80-\xff] |
1342\( # (
1343[^\\\x80-\xff\n\015()] * # normal*
1344(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1345\) # )
1346) # special
1347[^\\\x80-\xff\n\015()] * # normal*
1348)* # )*
1349\) # )
1350|
1351" # "
1352[^\\\x80-\xff\n\015"] * # normal
1353(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
1354" # "
1355) # "special" comment or quoted string
1356[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037] * # more "normal"
1357)*
1358<
1359[\040\t]* # Nab whitespace.
1360(?:
1361\( # (
1362[^\\\x80-\xff\n\015()] * # normal*
1363(?: # (
1364(?: \\ [^\x80-\xff] |
1365\( # (
1366[^\\\x80-\xff\n\015()] * # normal*
1367(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1368\) # )
1369) # special
1370[^\\\x80-\xff\n\015()] * # normal*
1371)* # )*
1372\) # )
1373[\040\t]* )* # If comment found, allow more spaces.
1374# <
1375(?:
1376@
1377[\040\t]* # Nab whitespace.
1378(?:
1379\( # (
1380[^\\\x80-\xff\n\015()] * # normal*
1381(?: # (
1382(?: \\ [^\x80-\xff] |
1383\( # (
1384[^\\\x80-\xff\n\015()] * # normal*
1385(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1386\) # )
1387) # special
1388[^\\\x80-\xff\n\015()] * # normal*
1389)* # )*
1390\) # )
1391[\040\t]* )* # If comment found, allow more spaces.
1392(?:
1393[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1394(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1395|
1396\[ # [
1397(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1398\] # ]
1399)
1400[\040\t]* # Nab whitespace.
1401(?:
1402\( # (
1403[^\\\x80-\xff\n\015()] * # normal*
1404(?: # (
1405(?: \\ [^\x80-\xff] |
1406\( # (
1407[^\\\x80-\xff\n\015()] * # normal*
1408(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1409\) # )
1410) # special
1411[^\\\x80-\xff\n\015()] * # normal*
1412)* # )*
1413\) # )
1414[\040\t]* )* # If comment found, allow more spaces.
1415# optional trailing comments
1416(?:
1417\.
1418[\040\t]* # Nab whitespace.
1419(?:
1420\( # (
1421[^\\\x80-\xff\n\015()] * # normal*
1422(?: # (
1423(?: \\ [^\x80-\xff] |
1424\( # (
1425[^\\\x80-\xff\n\015()] * # normal*
1426(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1427\) # )
1428) # special
1429[^\\\x80-\xff\n\015()] * # normal*
1430)* # )*
1431\) # )
1432[\040\t]* )* # If comment found, allow more spaces.
1433(?:
1434[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1435(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1436|
1437\[ # [
1438(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1439\] # ]
1440)
1441[\040\t]* # Nab whitespace.
1442(?:
1443\( # (
1444[^\\\x80-\xff\n\015()] * # normal*
1445(?: # (
1446(?: \\ [^\x80-\xff] |
1447\( # (
1448[^\\\x80-\xff\n\015()] * # normal*
1449(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1450\) # )
1451) # special
1452[^\\\x80-\xff\n\015()] * # normal*
1453)* # )*
1454\) # )
1455[\040\t]* )* # If comment found, allow more spaces.
1456# optional trailing comments
1457)*
1458(?: ,
1459[\040\t]* # Nab whitespace.
1460(?:
1461\( # (
1462[^\\\x80-\xff\n\015()] * # normal*
1463(?: # (
1464(?: \\ [^\x80-\xff] |
1465\( # (
1466[^\\\x80-\xff\n\015()] * # normal*
1467(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1468\) # )
1469) # special
1470[^\\\x80-\xff\n\015()] * # normal*
1471)* # )*
1472\) # )
1473[\040\t]* )* # If comment found, allow more spaces.
1474@
1475[\040\t]* # Nab whitespace.
1476(?:
1477\( # (
1478[^\\\x80-\xff\n\015()] * # normal*
1479(?: # (
1480(?: \\ [^\x80-\xff] |
1481\( # (
1482[^\\\x80-\xff\n\015()] * # normal*
1483(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1484\) # )
1485) # special
1486[^\\\x80-\xff\n\015()] * # normal*
1487)* # )*
1488\) # )
1489[\040\t]* )* # If comment found, allow more spaces.
1490(?:
1491[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1492(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1493|
1494\[ # [
1495(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1496\] # ]
1497)
1498[\040\t]* # Nab whitespace.
1499(?:
1500\( # (
1501[^\\\x80-\xff\n\015()] * # normal*
1502(?: # (
1503(?: \\ [^\x80-\xff] |
1504\( # (
1505[^\\\x80-\xff\n\015()] * # normal*
1506(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1507\) # )
1508) # special
1509[^\\\x80-\xff\n\015()] * # normal*
1510)* # )*
1511\) # )
1512[\040\t]* )* # If comment found, allow more spaces.
1513# optional trailing comments
1514(?:
1515\.
1516[\040\t]* # Nab whitespace.
1517(?:
1518\( # (
1519[^\\\x80-\xff\n\015()] * # normal*
1520(?: # (
1521(?: \\ [^\x80-\xff] |
1522\( # (
1523[^\\\x80-\xff\n\015()] * # normal*
1524(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1525\) # )
1526) # special
1527[^\\\x80-\xff\n\015()] * # normal*
1528)* # )*
1529\) # )
1530[\040\t]* )* # If comment found, allow more spaces.
1531(?:
1532[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1533(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1534|
1535\[ # [
1536(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1537\] # ]
1538)
1539[\040\t]* # Nab whitespace.
1540(?:
1541\( # (
1542[^\\\x80-\xff\n\015()] * # normal*
1543(?: # (
1544(?: \\ [^\x80-\xff] |
1545\( # (
1546[^\\\x80-\xff\n\015()] * # normal*
1547(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1548\) # )
1549) # special
1550[^\\\x80-\xff\n\015()] * # normal*
1551)* # )*
1552\) # )
1553[\040\t]* )* # If comment found, allow more spaces.
1554# optional trailing comments
1555)*
1556)* # additional domains
1557:
1558[\040\t]* # Nab whitespace.
1559(?:
1560\( # (
1561[^\\\x80-\xff\n\015()] * # normal*
1562(?: # (
1563(?: \\ [^\x80-\xff] |
1564\( # (
1565[^\\\x80-\xff\n\015()] * # normal*
1566(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1567\) # )
1568) # special
1569[^\\\x80-\xff\n\015()] * # normal*
1570)* # )*
1571\) # )
1572[\040\t]* )* # If comment found, allow more spaces.
1573# optional trailing comments
1574)? # optional route
1575(?:
1576[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1577(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1578# Atom
1579| # or
1580" # "
1581[^\\\x80-\xff\n\015"] * # normal
1582(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
1583" # "
1584# Quoted string
1585)
1586[\040\t]* # Nab whitespace.
1587(?:
1588\( # (
1589[^\\\x80-\xff\n\015()] * # normal*
1590(?: # (
1591(?: \\ [^\x80-\xff] |
1592\( # (
1593[^\\\x80-\xff\n\015()] * # normal*
1594(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1595\) # )
1596) # special
1597[^\\\x80-\xff\n\015()] * # normal*
1598)* # )*
1599\) # )
1600[\040\t]* )* # If comment found, allow more spaces.
1601(?:
1602\.
1603[\040\t]* # Nab whitespace.
1604(?:
1605\( # (
1606[^\\\x80-\xff\n\015()] * # normal*
1607(?: # (
1608(?: \\ [^\x80-\xff] |
1609\( # (
1610[^\\\x80-\xff\n\015()] * # normal*
1611(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1612\) # )
1613) # special
1614[^\\\x80-\xff\n\015()] * # normal*
1615)* # )*
1616\) # )
1617[\040\t]* )* # If comment found, allow more spaces.
1618(?:
1619[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1620(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1621# Atom
1622| # or
1623" # "
1624[^\\\x80-\xff\n\015"] * # normal
1625(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015"] * )* # ( special normal* )*
1626" # "
1627# Quoted string
1628)
1629[\040\t]* # Nab whitespace.
1630(?:
1631\( # (
1632[^\\\x80-\xff\n\015()] * # normal*
1633(?: # (
1634(?: \\ [^\x80-\xff] |
1635\( # (
1636[^\\\x80-\xff\n\015()] * # normal*
1637(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1638\) # )
1639) # special
1640[^\\\x80-\xff\n\015()] * # normal*
1641)* # )*
1642\) # )
1643[\040\t]* )* # If comment found, allow more spaces.
1644# additional words
1645)*
1646@
1647[\040\t]* # Nab whitespace.
1648(?:
1649\( # (
1650[^\\\x80-\xff\n\015()] * # normal*
1651(?: # (
1652(?: \\ [^\x80-\xff] |
1653\( # (
1654[^\\\x80-\xff\n\015()] * # normal*
1655(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1656\) # )
1657) # special
1658[^\\\x80-\xff\n\015()] * # normal*
1659)* # )*
1660\) # )
1661[\040\t]* )* # If comment found, allow more spaces.
1662(?:
1663[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1664(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1665|
1666\[ # [
1667(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1668\] # ]
1669)
1670[\040\t]* # Nab whitespace.
1671(?:
1672\( # (
1673[^\\\x80-\xff\n\015()] * # normal*
1674(?: # (
1675(?: \\ [^\x80-\xff] |
1676\( # (
1677[^\\\x80-\xff\n\015()] * # normal*
1678(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1679\) # )
1680) # special
1681[^\\\x80-\xff\n\015()] * # normal*
1682)* # )*
1683\) # )
1684[\040\t]* )* # If comment found, allow more spaces.
1685# optional trailing comments
1686(?:
1687\.
1688[\040\t]* # Nab whitespace.
1689(?:
1690\( # (
1691[^\\\x80-\xff\n\015()] * # normal*
1692(?: # (
1693(?: \\ [^\x80-\xff] |
1694\( # (
1695[^\\\x80-\xff\n\015()] * # normal*
1696(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1697\) # )
1698) # special
1699[^\\\x80-\xff\n\015()] * # normal*
1700)* # )*
1701\) # )
1702[\040\t]* )* # If comment found, allow more spaces.
1703(?:
1704[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+ # some number of atom characters...
1705(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]) # ..not followed by something that could be part of an atom
1706|
1707\[ # [
1708(?: [^\\\x80-\xff\n\015\[\]] | \\ [^\x80-\xff] )* # stuff
1709\] # ]
1710)
1711[\040\t]* # Nab whitespace.
1712(?:
1713\( # (
1714[^\\\x80-\xff\n\015()] * # normal*
1715(?: # (
1716(?: \\ [^\x80-\xff] |
1717\( # (
1718[^\\\x80-\xff\n\015()] * # normal*
1719(?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)*
1720\) # )
1721) # special
1722[^\\\x80-\xff\n\015()] * # normal*
1723)* # )*
1724\) # )
1725[\040\t]* )* # If comment found, allow more spaces.
1726# optional trailing comments
1727)*
1728# address spec
1729> # >
1730# name and address
1731)
1732/x
1733 Alan Other <user\@dom.ain>
1734 <user\@dom.ain>
1735 user\@dom.ain
1736 \"A. Other\" <user.1234\@dom.ain> (a comment)
1737 A. Other <user.1234\@dom.ain> (a comment)
1738 \"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"\@x400-re.lay
1739 A missing angle <user\@some.where
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001740\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001741 The quick brown fox
1742
1743/abc\0def\00pqr\000xyz\0000AB/
1744 abc\0def\00pqr\000xyz\0000AB
1745 abc456 abc\0def\00pqr\000xyz\0000ABCDE
1746
1747/abc\x0def\x00pqr\x000xyz\x0000AB/
1748 abc\x0def\x00pqr\x000xyz\x0000AB
1749 abc456 abc\x0def\x00pqr\x000xyz\x0000ABCDE
1750
1751/^[\000-\037]/
1752 \0A
1753 \01B
1754 \037C
1755
1756/\0*/
1757 \0\0\0\0
1758
1759/A\x0{2,3}Z/
1760 The A\x0\x0Z
1761 An A\0\x0\0Z
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001762\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001763 A\0Z
1764 A\0\x0\0\x0Z
1765
1766/^\s/
1767 \040abc
1768 \x0cabc
1769 \nabc
1770 \rabc
1771 \tabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001772\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001773 abc
1774
1775/^a b
1776 c/x
1777 abc
1778
1779/ab{1,3}bc/
1780 abbbbc
1781 abbbc
1782 abbc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001783\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001784 abc
1785 abbbbbc
1786
1787/([^.]*)\.([^:]*):[T ]+(.*)/
1788 track1.title:TBlah blah blah
1789
1790/([^.]*)\.([^:]*):[T ]+(.*)/i
1791 track1.title:TBlah blah blah
1792
1793/([^.]*)\.([^:]*):[t ]+(.*)/i
1794 track1.title:TBlah blah blah
1795
1796/^[W-c]+$/
1797 WXY_^abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001798\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001799 wxy
1800
1801/^[W-c]+$/i
1802 WXY_^abc
1803 wxy_^ABC
1804
1805/^[\x3f-\x5F]+$/i
1806 WXY_^abc
1807 wxy_^ABC
1808
1809/^abc$/m
1810 abc
1811 qqq\nabc
1812 abc\nzzz
1813 qqq\nabc\nzzz
1814
1815/^abc$/
1816 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001817\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001818 qqq\nabc
1819 abc\nzzz
1820 qqq\nabc\nzzz
1821
1822/\Aabc\Z/m
1823 abc
1824 abc\n
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001825\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001826 qqq\nabc
1827 abc\nzzz
1828 qqq\nabc\nzzz
1829
1830/\A(.)*\Z/s
1831 abc\ndef
1832
1833/\A(.)*\Z/m
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001834\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001835 abc\ndef
1836
1837/(?:b)|(?::+)/
1838 b::c
1839 c::b
1840
1841/[-az]+/
1842 az-
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001843\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001844 b
1845
1846/[az-]+/
1847 za-
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001848\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001849 b
1850
1851/[a\-z]+/
1852 a-z
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001853\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001854 b
1855
1856/[a-z]+/
1857 abcdxyz
1858
1859/[\d-]+/
1860 12-34
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001861\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001862 aaa
1863
Nick Kralevichf73ff172014-09-27 12:41:49 -07001864/\x5c/
1865 \\
1866
1867/\x20Z/
1868 the Zoo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001869\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001870 Zulu
1871
1872/ab{3cd/
1873 ab{3cd
1874
1875/ab{3,cd/
1876 ab{3,cd
1877
1878/ab{3,4a}cd/
1879 ab{3,4a}cd
1880
1881/{4,5a}bc/
1882 {4,5a}bc
1883
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001884/^a.b/newline=lf
Nick Kralevichf73ff172014-09-27 12:41:49 -07001885 a\rb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001886\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001887 a\nb
1888
1889/abc$/
1890 abc
1891 abc\n
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001892\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001893 abc\ndef
1894
1895/(abc)\123/
1896 abc\x53
1897
1898/(abc)\223/
1899 abc\x93
1900
1901/(abc)\323/
1902 abc\xd3
1903
1904/(abc)\100/
1905 abc\x40
1906 abc\100
1907
1908/(abc)\1000/
1909 abc\x400
1910 abc\x40\x30
1911 abc\1000
1912 abc\100\x30
1913 abc\100\060
1914 abc\100\60
1915
Nick Kralevichf73ff172014-09-27 12:41:49 -07001916/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123/
1917 abcdefghijk\12S
1918
Nick Kralevichf73ff172014-09-27 12:41:49 -07001919/a{0}bc/
1920 bc
1921
1922/(a|(bc)){0,0}?xyz/
1923 xyz
1924
1925/abc[\10]de/
1926 abc\010de
1927
1928/abc[\1]de/
1929 abc\1de
1930
1931/(abc)[\1]de/
1932 abc\1de
1933
1934/(?s)a.b/
1935 a\nb
1936
1937/^([^a])([^\b])([^c]*)([^d]{3,4})/
1938 baNOTccccd
1939 baNOTcccd
1940 baNOTccd
1941 bacccd
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001942\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001943 anything
1944 b\bc
1945 baccd
1946
1947/[^a]/
1948 Abc
1949
1950/[^a]/i
1951 Abc
1952
1953/[^a]+/
1954 AAAaAbc
1955
1956/[^a]+/i
1957 AAAaAbc
1958
1959/[^a]+/
1960 bbb\nccc
1961
1962/[^k]$/
1963 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001964\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001965 abk
1966
1967/[^k]{2,3}$/
1968 abc
1969 kbc
1970 kabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001971\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001972 abk
1973 akb
1974 akk
1975
1976/^\d{8,}\@.+[^k]$/
1977 12345678\@a.b.c.d
1978 123456789\@x.y.z
Janis Danisevskis53e448c2016-03-31 13:35:25 +01001979\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07001980 12345678\@x.y.uk
1981 1234567\@a.b.c.d
1982
1983/[^a]/
1984 aaaabcd
1985 aaAabcd
1986
1987/[^a]/i
1988 aaaabcd
1989 aaAabcd
1990
1991/[^az]/
1992 aaaabcd
1993 aaAabcd
1994
1995/[^az]/i
1996 aaaabcd
1997 aaAabcd
1998
1999/\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/
2000 \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
2001
2002/P[^*]TAIRE[^*]{1,6}?LL/
2003 xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
2004
2005/P[^*]TAIRE[^*]{1,}?LL/
2006 xxxxxxxxxxxPSTAIREISLLxxxxxxxxx
2007
2008/(\.\d\d[1-9]?)\d+/
2009 1.230003938
2010 1.875000282
2011 1.235
2012
2013/(\.\d\d((?=0)|\d(?=\d)))/
2014 1.230003938
2015 1.875000282
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002016\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002017 1.235
2018
2019/a(?)b/
2020 ab
2021
2022/\b(foo)\s+(\w+)/i
2023 Food is on the foo table
2024
2025/foo(.*)bar/
2026 The food is under the bar in the barn.
2027
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002028/foo(.*?)bar/
Nick Kralevichf73ff172014-09-27 12:41:49 -07002029 The food is under the bar in the barn.
2030
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002031/(.*)(\d*)/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -07002032 I have 2 numbers: 53147
2033
2034/(.*)(\d+)/
2035 I have 2 numbers: 53147
2036
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002037/(.*?)(\d*)/no_auto_possess
Nick Kralevichf73ff172014-09-27 12:41:49 -07002038 I have 2 numbers: 53147
2039
2040/(.*?)(\d+)/
2041 I have 2 numbers: 53147
2042
2043/(.*)(\d+)$/
2044 I have 2 numbers: 53147
2045
2046/(.*?)(\d+)$/
2047 I have 2 numbers: 53147
2048
2049/(.*)\b(\d+)$/
2050 I have 2 numbers: 53147
2051
2052/(.*\D)(\d+)$/
2053 I have 2 numbers: 53147
2054
2055/^\D*(?!123)/
2056 ABC123
2057
2058/^(\D*)(?=\d)(?!123)/
2059 ABC445
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002060\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002061 ABC123
2062
2063/^[W-]46]/
2064 W46]789
2065 -46]789
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002066\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002067 Wall
2068 Zebra
2069 42
2070 [abcd]
2071 ]abcd[
2072
2073/^[W-\]46]/
2074 W46]789
2075 Wall
2076 Zebra
2077 Xylophone
2078 42
2079 [abcd]
2080 ]abcd[
2081 \\backslash
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002082\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002083 -46]789
2084 well
2085
2086/\d\d\/\d\d\/\d\d\d\d/
2087 01/01/2000
2088
2089/word (?:[a-zA-Z0-9]+ ){0,10}otherword/
2090 word cat dog elephant mussel cow horse canary baboon snake shark otherword
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002091\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002092 word cat dog elephant mussel cow horse canary baboon snake shark
2093
2094/word (?:[a-zA-Z0-9]+ ){0,300}otherword/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002095\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002096 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
2097
2098/^(a){0,0}/
2099 bcd
2100 abc
2101 aab
2102
2103/^(a){0,1}/
2104 bcd
2105 abc
2106 aab
2107
2108/^(a){0,2}/
2109 bcd
2110 abc
2111 aab
2112
2113/^(a){0,3}/
2114 bcd
2115 abc
2116 aab
2117 aaa
2118
2119/^(a){0,}/
2120 bcd
2121 abc
2122 aab
2123 aaa
2124 aaaaaaaa
2125
2126/^(a){1,1}/
Nick Kralevichf73ff172014-09-27 12:41:49 -07002127 abc
2128 aab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002129\= Expect no match
2130 bcd
Nick Kralevichf73ff172014-09-27 12:41:49 -07002131
2132/^(a){1,2}/
Nick Kralevichf73ff172014-09-27 12:41:49 -07002133 abc
2134 aab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002135\= Expect no match
2136 bcd
Nick Kralevichf73ff172014-09-27 12:41:49 -07002137
2138/^(a){1,3}/
Nick Kralevichf73ff172014-09-27 12:41:49 -07002139 abc
2140 aab
2141 aaa
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002142\= Expect no match
2143 bcd
Nick Kralevichf73ff172014-09-27 12:41:49 -07002144
2145/^(a){1,}/
Nick Kralevichf73ff172014-09-27 12:41:49 -07002146 abc
2147 aab
2148 aaa
2149 aaaaaaaa
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002150\= Expect no match
2151 bcd
Nick Kralevichf73ff172014-09-27 12:41:49 -07002152
2153/.*\.gif/
2154 borfle\nbib.gif\nno
2155
2156/.{0,}\.gif/
2157 borfle\nbib.gif\nno
2158
2159/.*\.gif/m
2160 borfle\nbib.gif\nno
2161
2162/.*\.gif/s
2163 borfle\nbib.gif\nno
2164
2165/.*\.gif/ms
2166 borfle\nbib.gif\nno
2167
2168/.*$/
2169 borfle\nbib.gif\nno
2170
2171/.*$/m
2172 borfle\nbib.gif\nno
2173
2174/.*$/s
2175 borfle\nbib.gif\nno
2176
2177/.*$/ms
2178 borfle\nbib.gif\nno
2179
2180/.*$/
2181 borfle\nbib.gif\nno\n
2182
2183/.*$/m
2184 borfle\nbib.gif\nno\n
2185
2186/.*$/s
2187 borfle\nbib.gif\nno\n
2188
2189/.*$/ms
2190 borfle\nbib.gif\nno\n
2191
2192/(.*X|^B)/
2193 abcde\n1234Xyz
2194 BarFoo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002195\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002196 abcde\nBar
2197
2198/(.*X|^B)/m
2199 abcde\n1234Xyz
2200 BarFoo
2201 abcde\nBar
2202
2203/(.*X|^B)/s
2204 abcde\n1234Xyz
2205 BarFoo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002206\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002207 abcde\nBar
2208
2209/(.*X|^B)/ms
2210 abcde\n1234Xyz
2211 BarFoo
2212 abcde\nBar
2213
2214/(?s)(.*X|^B)/
2215 abcde\n1234Xyz
2216 BarFoo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002217\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002218 abcde\nBar
2219
2220/(?s:.*X|^B)/
2221 abcde\n1234Xyz
2222 BarFoo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002223\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002224 abcde\nBar
2225
2226/^.*B/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002227\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002228 abc\nB
2229
2230/(?s)^.*B/
2231 abc\nB
2232
2233/(?m)^.*B/
2234 abc\nB
2235
2236/(?ms)^.*B/
2237 abc\nB
2238
2239/(?ms)^B/
2240 abc\nB
2241
2242/(?s)B$/
2243 B\n
2244
2245/^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/
2246 123456654321
2247
2248/^\d\d\d\d\d\d\d\d\d\d\d\d/
2249 123456654321
2250
2251/^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]/
2252 123456654321
2253
2254/^[abc]{12}/
2255 abcabcabcabc
2256
2257/^[a-c]{12}/
2258 abcabcabcabc
2259
2260/^(a|b|c){12}/
2261 abcabcabcabc
2262
2263/^[abcdefghijklmnopqrstuvwxy0123456789]/
2264 n
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002265\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002266 z
2267
2268/abcde{0,0}/
2269 abcd
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002270\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002271 abce
2272
2273/ab[cd]{0,0}e/
2274 abe
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002275\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002276 abcde
2277
2278/ab(c){0,0}d/
2279 abd
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002280\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002281 abcd
2282
2283/a(b*)/
2284 a
2285 ab
2286 abbbb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002287\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002288 bbbbb
2289
2290/ab\d{0}e/
2291 abe
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002292\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002293 ab1e
2294
2295/"([^\\"]+|\\.)*"/
2296 the \"quick\" brown fox
2297 \"the \\\"quick\\\" brown fox\"
2298
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002299/.*?/g,aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07002300 abc
2301
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002302/\b/g,aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07002303 abc
2304
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002305/\b/g,aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07002306 abc
2307
2308//g
2309 abc
2310
2311/<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
2312 <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>
2313
2314/a[^a]b/
2315 acb
2316 a\nb
2317
2318/a.b/
2319 acb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002320\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002321 a\nb
2322
2323/a[^a]b/s
2324 acb
2325 a\nb
2326
2327/a.b/s
2328 acb
2329 a\nb
2330
2331/^(b+?|a){1,2}?c/
2332 bac
2333 bbac
2334 bbbac
2335 bbbbac
2336 bbbbbac
2337
2338/^(b+|a){1,2}?c/
2339 bac
2340 bbac
2341 bbbac
2342 bbbbac
2343 bbbbbac
2344
2345/(?!\A)x/m
Nick Kralevichf73ff172014-09-27 12:41:49 -07002346 a\bx\n
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002347\= Expect no match
2348 x\nb\n
Nick Kralevichf73ff172014-09-27 12:41:49 -07002349
2350/\x0{ab}/
2351 \0{ab}
2352
2353/(A|B)*?CD/
2354 CD
2355
2356/(A|B)*CD/
2357 CD
2358
2359/(?<!bar)foo/
2360 foo
2361 catfood
2362 arfootle
2363 rfoosh
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002364\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002365 barfoo
2366 towbarfoo
2367
2368/\w{3}(?<!bar)foo/
2369 catfood
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002370\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002371 foo
2372 barfoo
2373 towbarfoo
2374
2375/(?<=(foo)a)bar/
2376 fooabar
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002377\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002378 bar
2379 foobbar
2380
2381/\Aabc\z/m
2382 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002383\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002384 abc\n
2385 qqq\nabc
2386 abc\nzzz
2387 qqq\nabc\nzzz
2388
2389"(?>.*/)foo"
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002390\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002391 /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/
2392
2393"(?>.*/)foo"
2394 /this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo
2395
2396/(?>(\.\d\d[1-9]?))\d+/
2397 1.230003938
2398 1.875000282
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002399\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002400 1.235
2401
2402/^((?>\w+)|(?>\s+))*$/
2403 now is the time for all good men to come to the aid of the party
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002404\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002405 this is not a line with only words and spaces!
2406
2407/(\d+)(\w)/
2408 12345a
2409 12345+
2410
2411/((?>\d+))(\w)/
2412 12345a
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002413\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002414 12345+
2415
2416/(?>a+)b/
2417 aaab
2418
2419/((?>a+)b)/
2420 aaab
2421
2422/(?>(a+))b/
2423 aaab
2424
2425/(?>b)+/
2426 aaabbbccc
2427
2428/(?>a+|b+|c+)*c/
2429 aaabbbbccccd
2430
2431/(a+|b+|c+)*c/
2432 aaabbbbccccd
2433
2434/((?>[^()]+)|\([^()]*\))+/
2435 ((abc(ade)ufh()()x
2436
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002437/\(((?>[^()]+)|\([^()]+\))+\)/
Nick Kralevichf73ff172014-09-27 12:41:49 -07002438 (abc)
2439 (abc(def)xyz)
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002440\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002441 ((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2442
2443/a(?-i)b/i
2444 ab
2445 Ab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002446\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002447 aB
2448 AB
2449
2450/(a (?x)b c)d e/
2451 a bcd e
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002452\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002453 a b cd e
2454 abcd e
2455 a bcde
2456
2457/(a b(?x)c d (?-x)e f)/
2458 a bcde f
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002459\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002460 abcdef
2461
2462/(a(?i)b)c/
2463 abc
2464 aBc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002465\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002466 abC
2467 aBC
2468 Abc
2469 ABc
2470 ABC
2471 AbC
2472
2473/a(?i:b)c/
2474 abc
2475 aBc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002476\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002477 ABC
2478 abC
2479 aBC
2480
2481/a(?i:b)*c/
2482 aBc
2483 aBBc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002484\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002485 aBC
2486 aBBC
2487
2488/a(?=b(?i)c)\w\wd/
2489 abcd
2490 abCd
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002491\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002492 aBCd
2493 abcD
2494
2495/(?s-i:more.*than).*million/i
2496 more than million
2497 more than MILLION
2498 more \n than Million
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002499\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002500 MORE THAN MILLION
2501 more \n than \n million
2502
2503/(?:(?s-i)more.*than).*million/i
2504 more than million
2505 more than MILLION
2506 more \n than Million
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002507\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002508 MORE THAN MILLION
2509 more \n than \n million
2510
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002511/(?>a(?i)b+)+c/
Nick Kralevichf73ff172014-09-27 12:41:49 -07002512 abc
2513 aBbc
2514 aBBc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002515\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002516 Abc
2517 abAb
2518 abbC
2519
2520/(?=a(?i)b)\w\wc/
2521 abc
2522 aBc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002523\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002524 Ab
2525 abC
2526 aBC
2527
2528/(?<=a(?i)b)(\w\w)c/
2529 abxxc
2530 aBxxc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002531\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002532 Abxxc
2533 ABxxc
2534 abxxC
2535
2536/^(?(?=abc)\w{3}:|\d\d)$/
2537 abc:
2538 12
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002539\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002540 123
2541 xyz
2542
2543/^(?(?!abc)\d\d|\w{3}:)$/
2544 abc:
2545 12
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002546\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002547 123
2548 xyz
2549
2550/(?(?<=foo)bar|cat)/
2551 foobar
2552 cat
2553 fcat
2554 focat
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002555\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002556 foocat
2557
2558/(?(?<!foo)cat|bar)/
2559 foobar
2560 cat
2561 fcat
2562 focat
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002563\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002564 foocat
2565
2566/(?>a*)*/
2567 a
2568 aa
2569 aaaa
2570
2571/(abc|)+/
2572 abc
2573 abcabc
2574 abcabcabc
2575 xyz
2576
2577/([a]*)*/
2578 a
2579 aaaaa
2580
2581/([ab]*)*/
2582 a
2583 b
2584 ababab
2585 aaaabcde
2586 bbbb
2587
2588/([^a]*)*/
2589 b
2590 bbbb
2591 aaa
2592
2593/([^ab]*)*/
2594 cccc
2595 abab
2596
2597/([a]*?)*/
2598 a
2599 aaaa
2600
2601/([ab]*?)*/
2602 a
2603 b
2604 abab
2605 baba
2606
2607/([^a]*?)*/
2608 b
2609 bbbb
2610 aaa
2611
2612/([^ab]*?)*/
2613 c
2614 cccc
2615 baba
2616
2617/(?>a*)*/
2618 a
2619 aaabcde
2620
2621/((?>a*))*/
2622 aaaaa
2623 aabbaa
2624
2625/((?>a*?))*/
2626 aaaaa
2627 aabbaa
2628
2629/(?(?=[^a-z]+[a-z]) \d{2}-[a-z]{3}-\d{2} | \d{2}-\d{2}-\d{2} ) /x
2630 12-sep-98
2631 12-09-98
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002632\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002633 sep-12-98
2634
2635/(?i:saturday|sunday)/
2636 saturday
2637 sunday
2638 Saturday
2639 Sunday
2640 SATURDAY
2641 SUNDAY
2642 SunDay
2643
2644/(a(?i)bc|BB)x/
2645 abcx
2646 aBCx
2647 bbx
2648 BBx
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002649\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002650 abcX
2651 aBCX
2652 bbX
2653 BBX
2654
2655/^([ab](?i)[cd]|[ef])/
2656 ac
2657 aC
2658 bD
2659 elephant
2660 Europe
2661 frog
2662 France
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002663\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002664 Africa
2665
2666/^(ab|a(?i)[b-c](?m-i)d|x(?i)y|z)/
2667 ab
2668 aBd
2669 xy
2670 xY
2671 zebra
2672 Zambesi
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002673\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002674 aCD
2675 XY
2676
2677/(?<=foo\n)^bar/m
2678 foo\nbar
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002679\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002680 bar
2681 baz\nbar
2682
2683/(?<=(?<!foo)bar)baz/
2684 barbaz
2685 barbarbaz
2686 koobarbaz
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002687\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002688 baz
2689 foobarbaz
2690
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002691# The following tests are taken from the Perl 5.005 test suite; some of them
2692# are compatible with 5.004, but I'd rather not have to sort them out.
Nick Kralevichf73ff172014-09-27 12:41:49 -07002693
2694/abc/
2695 abc
2696 xabcy
2697 ababc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002698\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002699 xbc
2700 axc
2701 abx
2702
2703/ab*c/
2704 abc
2705
2706/ab*bc/
2707 abc
2708 abbc
2709 abbbbc
2710
2711/.{1}/
2712 abbbbc
2713
2714/.{3,4}/
2715 abbbbc
2716
2717/ab{0,}bc/
2718 abbbbc
2719
2720/ab+bc/
2721 abbc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002722\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002723 abc
2724 abq
2725
2726/ab+bc/
2727 abbbbc
2728
2729/ab{1,}bc/
2730 abbbbc
2731
2732/ab{1,3}bc/
2733 abbbbc
2734
2735/ab{3,4}bc/
2736 abbbbc
2737
2738/ab{4,5}bc/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002739\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002740 abq
2741 abbbbc
2742
2743/ab?bc/
2744 abbc
2745 abc
2746
2747/ab{0,1}bc/
2748 abc
2749
2750/ab?bc/
2751
2752/ab?c/
2753 abc
2754
2755/ab{0,1}c/
2756 abc
2757
2758/^abc$/
2759 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002760\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002761 abbbbc
2762 abcc
2763
2764/^abc/
2765 abcc
2766
2767/^abc$/
2768
2769/abc$/
2770 aabc
Nick Kralevichf73ff172014-09-27 12:41:49 -07002771 aabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002772\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002773 aabcd
2774
2775/^/
2776 abc
2777
2778/$/
2779 abc
2780
2781/a.c/
2782 abc
2783 axc
2784
2785/a.*c/
2786 axyzc
2787
2788/a[bc]d/
2789 abd
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002790\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002791 axyzd
2792 abc
2793
2794/a[b-d]e/
2795 ace
2796
2797/a[b-d]/
2798 aac
2799
2800/a[-b]/
2801 a-
2802
2803/a[b-]/
2804 a-
2805
2806/a]/
2807 a]
2808
2809/a[]]b/
2810 a]b
2811
2812/a[^bc]d/
2813 aed
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002814\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002815 abd
2816 abd
2817
2818/a[^-b]c/
2819 adc
2820
2821/a[^]b]c/
2822 adc
Nick Kralevichf73ff172014-09-27 12:41:49 -07002823 a-c
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002824\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002825 a]c
2826
2827/\ba\b/
2828 a-
2829 -a
2830 -a-
2831
2832/\by\b/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002833\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002834 xy
2835 yz
2836 xyz
2837
2838/\Ba\B/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002839\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002840 a-
2841 -a
2842 -a-
2843
2844/\By\b/
2845 xy
2846
2847/\by\B/
2848 yz
2849
2850/\By\B/
2851 xyz
2852
2853/\w/
2854 a
2855
2856/\W/
2857 -
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002858\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002859 a
2860
2861/a\sb/
2862 a b
2863
2864/a\Sb/
2865 a-b
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002866\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002867 a b
2868
2869/\d/
2870 1
2871
2872/\D/
2873 -
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002874\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002875 1
2876
2877/[\w]/
2878 a
2879
2880/[\W]/
2881 -
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002882\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002883 a
2884
2885/a[\s]b/
2886 a b
2887
2888/a[\S]b/
2889 a-b
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002890\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002891 a b
2892
2893/[\d]/
2894 1
2895
2896/[\D]/
2897 -
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002898\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002899 1
2900
2901/ab|cd/
2902 abc
2903 abcd
2904
2905/()ef/
2906 def
2907
2908/$b/
2909
2910/a\(b/
2911 a(b
2912
2913/a\(*b/
2914 ab
2915 a((b
2916
2917/a\\b/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002918 a\\b
2919\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002920 a\b
2921
2922/((a))/
2923 abc
2924
2925/(a)b(c)/
2926 abc
2927
2928/a+b+c/
2929 aabbabc
2930
2931/a{1,}b{1,}c/
2932 aabbabc
2933
2934/a.+?c/
2935 abcabc
2936
2937/(a+|b)*/
2938 ab
2939
2940/(a+|b){0,}/
2941 ab
2942
2943/(a+|b)+/
2944 ab
2945
2946/(a+|b){1,}/
2947 ab
2948
2949/(a+|b)?/
2950 ab
2951
2952/(a+|b){0,1}/
2953 ab
2954
2955/[^ab]*/
2956 cde
2957
2958/abc/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01002959\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07002960 b
Nick Kralevichf73ff172014-09-27 12:41:49 -07002961
2962/a*/
Nick Kralevichf73ff172014-09-27 12:41:49 -07002963
2964/([abc])*d/
2965 abbbcd
2966
2967/([abc])*bcd/
2968 abcd
2969
2970/a|b|c|d|e/
2971 e
2972
2973/(a|b|c|d|e)f/
2974 ef
2975
2976/abcd*efg/
2977 abcdefg
2978
2979/ab*/
2980 xabyabbbz
2981 xayabbbz
2982
2983/(ab|cd)e/
2984 abcde
2985
2986/[abhgefdc]ij/
2987 hij
2988
2989/^(ab|cd)e/
2990
2991/(abc|)ef/
2992 abcdef
2993
2994/(a|b)c*d/
2995 abcd
2996
2997/(ab|ab*)bc/
2998 abc
2999
3000/a([bc]*)c*/
3001 abc
3002
3003/a([bc]*)(c*d)/
3004 abcd
3005
3006/a([bc]+)(c*d)/
3007 abcd
3008
3009/a([bc]*)(c+d)/
3010 abcd
3011
3012/a[bcd]*dcdcde/
3013 adcdcde
3014
3015/a[bcd]+dcdcde/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003016\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003017 abcde
3018 adcdcde
3019
3020/(ab|a)b*c/
3021 abc
3022
3023/((a)(b)c)(d)/
3024 abcd
3025
3026/[a-zA-Z_][a-zA-Z0-9_]*/
3027 alpha
3028
3029/^a(bc+|b[eh])g|.h$/
3030 abh
3031
3032/(bc+d$|ef*g.|h?i(j|k))/
3033 effgz
3034 ij
3035 reffgz
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003036\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003037 effg
3038 bcdd
3039
3040/((((((((((a))))))))))/
3041 a
3042
3043/(((((((((a)))))))))/
3044 a
3045
3046/multiple words of text/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003047\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003048 aa
3049 uh-uh
3050
3051/multiple words/
3052 multiple words, yeah
3053
3054/(.*)c(.*)/
3055 abcde
3056
3057/\((.*), (.*)\)/
3058 (a, b)
3059
3060/[k]/
3061
3062/abcd/
3063 abcd
3064
3065/a(bc)d/
3066 abcd
3067
3068/a[-]?c/
3069 ac
3070
3071/abc/i
3072 ABC
3073 XABCY
3074 ABABC
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003075\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003076 aaxabxbaxbbx
3077 XBC
3078 AXC
3079 ABX
3080
3081/ab*c/i
3082 ABC
3083
3084/ab*bc/i
3085 ABC
3086 ABBC
3087
3088/ab*?bc/i
3089 ABBBBC
3090
3091/ab{0,}?bc/i
3092 ABBBBC
3093
3094/ab+?bc/i
3095 ABBC
3096
3097/ab+bc/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003098\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003099 ABC
3100 ABQ
3101
3102/ab{1,}bc/i
3103
3104/ab+bc/i
3105 ABBBBC
3106
3107/ab{1,}?bc/i
3108 ABBBBC
3109
3110/ab{1,3}?bc/i
3111 ABBBBC
3112
3113/ab{3,4}?bc/i
3114 ABBBBC
3115
3116/ab{4,5}?bc/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003117\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003118 ABQ
3119 ABBBBC
3120
3121/ab??bc/i
3122 ABBC
3123 ABC
3124
3125/ab{0,1}?bc/i
3126 ABC
3127
3128/ab??bc/i
3129
3130/ab??c/i
3131 ABC
3132
3133/ab{0,1}?c/i
3134 ABC
3135
3136/^abc$/i
3137 ABC
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003138\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003139 ABBBBC
3140 ABCC
3141
3142/^abc/i
3143 ABCC
3144
3145/^abc$/i
3146
3147/abc$/i
3148 AABC
3149
3150/^/i
3151 ABC
3152
3153/$/i
3154 ABC
3155
3156/a.c/i
3157 ABC
3158 AXC
3159
3160/a.*?c/i
3161 AXYZC
3162
3163/a.*c/i
Nick Kralevichf73ff172014-09-27 12:41:49 -07003164 AABC
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003165\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003166 AXYZD
3167
3168/a[bc]d/i
3169 ABD
3170
3171/a[b-d]e/i
3172 ACE
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003173\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003174 ABC
3175 ABD
3176
3177/a[b-d]/i
3178 AAC
3179
3180/a[-b]/i
3181 A-
3182
3183/a[b-]/i
3184 A-
3185
3186/a]/i
3187 A]
3188
3189/a[]]b/i
3190 A]B
3191
3192/a[^bc]d/i
3193 AED
3194
3195/a[^-b]c/i
3196 ADC
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003197\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003198 ABD
3199 A-C
3200
3201/a[^]b]c/i
3202 ADC
3203
3204/ab|cd/i
3205 ABC
3206 ABCD
3207
3208/()ef/i
3209 DEF
3210
3211/$b/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003212\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003213 A]C
3214 B
3215
3216/a\(b/i
3217 A(B
3218
3219/a\(*b/i
3220 AB
3221 A((B
3222
3223/a\\b/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003224\= Expect no match
3225 A\=notbol
Nick Kralevichf73ff172014-09-27 12:41:49 -07003226
3227/((a))/i
3228 ABC
3229
3230/(a)b(c)/i
3231 ABC
3232
3233/a+b+c/i
3234 AABBABC
3235
3236/a{1,}b{1,}c/i
3237 AABBABC
3238
3239/a.+?c/i
3240 ABCABC
3241
3242/a.*?c/i
3243 ABCABC
3244
3245/a.{0,5}?c/i
3246 ABCABC
3247
3248/(a+|b)*/i
3249 AB
3250
3251/(a+|b){0,}/i
3252 AB
3253
3254/(a+|b)+/i
3255 AB
3256
3257/(a+|b){1,}/i
3258 AB
3259
3260/(a+|b)?/i
3261 AB
3262
3263/(a+|b){0,1}/i
3264 AB
3265
3266/(a+|b){0,1}?/i
3267 AB
3268
3269/[^ab]*/i
3270 CDE
3271
3272/abc/i
3273
3274/a*/i
Nick Kralevichf73ff172014-09-27 12:41:49 -07003275
3276/([abc])*d/i
3277 ABBBCD
3278
3279/([abc])*bcd/i
3280 ABCD
3281
3282/a|b|c|d|e/i
3283 E
3284
3285/(a|b|c|d|e)f/i
3286 EF
3287
3288/abcd*efg/i
3289 ABCDEFG
3290
3291/ab*/i
3292 XABYABBBZ
3293 XAYABBBZ
3294
3295/(ab|cd)e/i
3296 ABCDE
3297
3298/[abhgefdc]ij/i
3299 HIJ
3300
3301/^(ab|cd)e/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003302\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003303 ABCDE
3304
3305/(abc|)ef/i
3306 ABCDEF
3307
3308/(a|b)c*d/i
3309 ABCD
3310
3311/(ab|ab*)bc/i
3312 ABC
3313
3314/a([bc]*)c*/i
3315 ABC
3316
3317/a([bc]*)(c*d)/i
3318 ABCD
3319
3320/a([bc]+)(c*d)/i
3321 ABCD
3322
3323/a([bc]*)(c+d)/i
3324 ABCD
3325
3326/a[bcd]*dcdcde/i
3327 ADCDCDE
3328
3329/a[bcd]+dcdcde/i
3330
3331/(ab|a)b*c/i
3332 ABC
3333
3334/((a)(b)c)(d)/i
3335 ABCD
3336
3337/[a-zA-Z_][a-zA-Z0-9_]*/i
3338 ALPHA
3339
3340/^a(bc+|b[eh])g|.h$/i
3341 ABH
3342
3343/(bc+d$|ef*g.|h?i(j|k))/i
3344 EFFGZ
3345 IJ
3346 REFFGZ
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003347\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003348 ADCDCDE
3349 EFFG
3350 BCDD
3351
3352/((((((((((a))))))))))/i
3353 A
3354
3355/(((((((((a)))))))))/i
3356 A
3357
3358/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i
3359 A
3360
3361/(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i
3362 C
3363
3364/multiple words of text/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003365\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003366 AA
3367 UH-UH
3368
3369/multiple words/i
3370 MULTIPLE WORDS, YEAH
3371
3372/(.*)c(.*)/i
3373 ABCDE
3374
3375/\((.*), (.*)\)/i
3376 (A, B)
3377
3378/[k]/i
3379
3380/abcd/i
3381 ABCD
3382
3383/a(bc)d/i
3384 ABCD
3385
3386/a[-]?c/i
3387 AC
3388
3389/a(?!b)./
3390 abad
3391
3392/a(?=d)./
3393 abad
3394
3395/a(?=c|d)./
3396 abad
3397
3398/a(?:b|c|d)(.)/
3399 ace
3400
3401/a(?:b|c|d)*(.)/
3402 ace
3403
3404/a(?:b|c|d)+?(.)/
3405 ace
3406 acdbcdbe
3407
3408/a(?:b|c|d)+(.)/
3409 acdbcdbe
3410
3411/a(?:b|c|d){2}(.)/
3412 acdbcdbe
3413
3414/a(?:b|c|d){4,5}(.)/
3415 acdbcdbe
3416
3417/a(?:b|c|d){4,5}?(.)/
3418 acdbcdbe
3419
3420/((foo)|(bar))*/
3421 foobar
3422
3423/a(?:b|c|d){6,7}(.)/
3424 acdbcdbe
3425
3426/a(?:b|c|d){6,7}?(.)/
3427 acdbcdbe
3428
3429/a(?:b|c|d){5,6}(.)/
3430 acdbcdbe
3431
3432/a(?:b|c|d){5,6}?(.)/
3433 acdbcdbe
3434
3435/a(?:b|c|d){5,7}(.)/
3436 acdbcdbe
3437
3438/a(?:b|c|d){5,7}?(.)/
3439 acdbcdbe
3440
3441/a(?:b|(c|e){1,2}?|d)+?(.)/
3442 ace
3443
3444/^(.+)?B/
3445 AB
3446
3447/^([^a-z])|(\^)$/
3448 .
3449
3450/^[<>]&/
3451 <&OUT
3452
3453/(?:(f)(o)(o)|(b)(a)(r))*/
3454 foobar
3455
3456/(?<=a)b/
3457 ab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003458\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003459 cb
3460 b
3461
3462/(?<!c)b/
3463 ab
3464 b
3465 b
3466
3467/(?:..)*a/
3468 aba
3469
3470/(?:..)*?a/
3471 aba
3472
3473/^(){3,5}/
3474 abc
3475
3476/^(a+)*ax/
3477 aax
3478
3479/^((a|b)+)*ax/
3480 aax
3481
3482/^((a|bc)+)*ax/
3483 aax
3484
3485/(a|x)*ab/
3486 cab
3487
3488/(a)*ab/
3489 cab
3490
3491/(?:(?i)a)b/
3492 ab
3493
3494/((?i)a)b/
3495 ab
3496
3497/(?:(?i)a)b/
3498 Ab
3499
3500/((?i)a)b/
3501 Ab
3502
3503/(?:(?i)a)b/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003504\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003505 cb
3506 aB
3507
3508/((?i)a)b/
3509
3510/(?i:a)b/
3511 ab
3512
3513/((?i:a))b/
3514 ab
3515
3516/(?i:a)b/
3517 Ab
3518
3519/((?i:a))b/
3520 Ab
3521
3522/(?i:a)b/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003523\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003524 aB
3525 aB
3526
3527/((?i:a))b/
3528
3529/(?:(?-i)a)b/i
3530 ab
3531
3532/((?-i)a)b/i
3533 ab
3534
3535/(?:(?-i)a)b/i
3536 aB
3537
3538/((?-i)a)b/i
3539 aB
3540
3541/(?:(?-i)a)b/i
Nick Kralevichf73ff172014-09-27 12:41:49 -07003542 aB
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003543\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003544 Ab
3545
3546/((?-i)a)b/i
3547
3548/(?:(?-i)a)b/i
3549 aB
3550
3551/((?-i)a)b/i
3552 aB
3553
3554/(?:(?-i)a)b/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003555\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003556 Ab
3557 AB
3558
3559/((?-i)a)b/i
3560
3561/(?-i:a)b/i
3562 ab
3563
3564/((?-i:a))b/i
3565 ab
3566
3567/(?-i:a)b/i
3568 aB
3569
3570/((?-i:a))b/i
3571 aB
3572
3573/(?-i:a)b/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003574\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003575 AB
3576 Ab
3577
3578/((?-i:a))b/i
3579
3580/(?-i:a)b/i
3581 aB
3582
3583/((?-i:a))b/i
3584 aB
3585
3586/(?-i:a)b/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003587\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003588 Ab
3589 AB
3590
3591/((?-i:a))b/i
3592
3593/((?-i:a.))b/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003594\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003595 AB
3596 a\nB
3597
3598/((?s-i:a.))b/i
3599 a\nB
3600
3601/(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/
3602 cabbbb
3603
3604/(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/
3605 caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
3606
3607/foo\w*\d{4}baz/
3608 foobar1234baz
3609
3610/x(~~)*(?:(?:F)?)?/
3611 x~~
3612
3613/^a(?#xxx){3}c/
3614 aaac
3615
3616/^a (?#xxx) (?#yyy) {3}c/x
3617 aaac
3618
3619/(?<![cd])b/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003620\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003621 B\nB
3622 dbcb
3623
3624/(?<![cd])[ab]/
3625 dbaacb
3626
3627/(?<!(c|d))b/
3628
3629/(?<!(c|d))[ab]/
3630 dbaacb
3631
3632/(?<!cd)[ab]/
3633 cdaccb
3634
3635/^(?:a?b?)*$/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003636\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003637 dbcb
3638 a--
3639
3640/((?s)^a(.))((?m)^b$)/
3641 a\nb\nc\n
3642
3643/((?m)^b$)/
3644 a\nb\nc\n
3645
3646/(?m)^b/
3647 a\nb\n
3648
3649/(?m)^(b)/
3650 a\nb\n
3651
3652/((?m)^b)/
3653 a\nb\n
3654
3655/\n((?m)^b)/
3656 a\nb\n
3657
3658/((?s).)c(?!.)/
3659 a\nb\nc\n
3660 a\nb\nc\n
3661
3662/((?s)b.)c(?!.)/
3663 a\nb\nc\n
3664 a\nb\nc\n
3665
3666/^b/
3667
3668/()^b/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003669\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003670 a\nb\nc\n
3671 a\nb\nc\n
3672
3673/((?m)^b)/
3674 a\nb\nc\n
3675
3676/(?(?!a)a|b)/
3677
3678/(?(?!a)b|a)/
3679 a
3680
3681/(?(?=a)b|a)/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003682\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003683 a
3684 a
3685
3686/(?(?=a)a|b)/
3687 a
3688
3689/(\w+:)+/
3690 one:
3691
3692/$(?<=^(a))/
3693 a
3694
3695/([\w:]+::)?(\w+)$/
3696 abcd
3697 xy:z:::abcd
3698
3699/^[^bcd]*(c+)/
3700 aexycd
3701
3702/(a*)b+/
3703 caab
3704
3705/([\w:]+::)?(\w+)$/
3706 abcd
3707 xy:z:::abcd
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003708\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003709 abcd:
3710 abcd:
3711
3712/^[^bcd]*(c+)/
3713 aexycd
3714
3715/(>a+)ab/
3716
3717/(?>a+)b/
3718 aaab
3719
3720/([[:]+)/
3721 a:[b]:
3722
3723/([[=]+)/
3724 a=[b]=
3725
3726/([[.]+)/
3727 a.[b].
3728
3729/((?>a+)b)/
3730 aaab
3731
3732/(?>(a+))b/
3733 aaab
3734
3735/((?>[^()]+)|\([^()]*\))+/
3736 ((abc(ade)ufh()()x
3737
3738/a\Z/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003739\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003740 aaab
3741 a\nb\n
3742
3743/b\Z/
3744 a\nb\n
3745
3746/b\z/
3747
3748/b\Z/
3749 a\nb
3750
3751/b\z/
3752 a\nb
Nick Kralevichf73ff172014-09-27 12:41:49 -07003753
3754/(?>.*)(?<=(abcd|wxyz))/
3755 alphabetabcd
3756 endingwxyz
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003757\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003758 a rather long string that doesn't end with one of them
3759
3760/word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword/
3761 word cat dog elephant mussel cow horse canary baboon snake shark otherword
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003762\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003763 word cat dog elephant mussel cow horse canary baboon snake shark
3764
3765/word (?>[a-zA-Z0-9]+ ){0,30}otherword/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003766\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003767 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
3768
3769/(?<=\d{3}(?!999))foo/
3770 999foo
3771 123999foo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003772\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003773 123abcfoo
3774
3775/(?<=(?!...999)\d{3})foo/
3776 999foo
3777 123999foo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003778\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003779 123abcfoo
3780
3781/(?<=\d{3}(?!999)...)foo/
3782 123abcfoo
3783 123456foo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003784\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003785 123999foo
3786
3787/(?<=\d{3}...)(?<!999)foo/
3788 123abcfoo
3789 123456foo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003790\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003791 123999foo
3792
3793/((Z)+|A)*/
3794 ZABCDEFG
3795
3796/(Z()|A)*/
3797 ZABCDEFG
3798
3799/(Z(())|A)*/
3800 ZABCDEFG
3801
3802/((?>Z)+|A)*/
3803 ZABCDEFG
3804
3805/((?>)+|A)*/
3806 ZABCDEFG
3807
3808/a*/g
3809 abbab
3810
Nick Kralevichf73ff172014-09-27 12:41:49 -07003811/[[:space:]]+/
3812 > \x09\x0a\x0c\x0d\x0b<
3813
3814/[[:blank:]]+/
3815 > \x09\x0a\x0c\x0d\x0b<
3816
3817/[\s]+/
3818 > \x09\x0a\x0c\x0d\x0b<
3819
3820/\s+/
3821 > \x09\x0a\x0c\x0d\x0b<
3822
3823/a b/x
3824 ab
3825
3826/(?!\A)x/m
3827 a\nxb\n
3828
3829/(?!^)x/m
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003830\= Expect no match
3831 a\nxb\n
Nick Kralevichf73ff172014-09-27 12:41:49 -07003832
3833/abc\Qabc\Eabc/
3834 abcabcabc
3835
3836/abc\Q(*+|\Eabc/
3837 abc(*+|abc
3838
3839/ abc\Q abc\Eabc/x
3840 abc abcabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003841\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003842 abcabcabc
3843
3844/abc#comment
3845 \Q#not comment
3846 literal\E/x
3847 abc#not comment\n literal
3848
3849/abc#comment
3850 \Q#not comment
3851 literal/x
3852 abc#not comment\n literal
3853
3854/abc#comment
3855 \Q#not comment
3856 literal\E #more comment
3857 /x
3858 abc#not comment\n literal
3859
3860/abc#comment
3861 \Q#not comment
3862 literal\E #more comment/x
3863 abc#not comment\n literal
3864
3865/\Qabc\$xyz\E/
3866 abc\\\$xyz
3867
3868/\Qabc\E\$\Qxyz\E/
3869 abc\$xyz
3870
3871/\Gabc/
3872 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003873\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003874 xyzabc
3875
3876/\Gabc./g
3877 abc1abc2xyzabc3
3878
3879/abc./g
3880 abc1abc2xyzabc3
3881
3882/a(?x: b c )d/
3883 XabcdY
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003884\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003885 Xa b c d Y
3886
3887/((?x)x y z | a b c)/
3888 XabcY
3889 AxyzB
3890
3891/(?i)AB(?-i)C/
3892 XabCY
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003893\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003894 XabcY
3895
3896/((?i)AB(?-i)C|D)E/
3897 abCE
3898 DE
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003899\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003900 abcE
3901 abCe
3902 dE
3903 De
3904
3905/[z\Qa-d]\E]/
3906 z
3907 a
3908 -
3909 d
3910 ]
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003911\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003912 b
3913
Nick Kralevichf73ff172014-09-27 12:41:49 -07003914/(a+)*b/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003915\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003916 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
3917
3918/(?i)reg(?:ul(?:[aä]|ae)r|ex)/
3919 REGular
3920 regulaer
3921 Regex
3922 regulär
3923
3924/Åæåä[à-ÿÀ-ß]+/
3925 Åæåäà
3926 Åæåäÿ
3927 ÅæåäÀ
3928 Åæåäß
3929
3930/(?<=Z)X./
3931 \x84XAZXB
3932
3933/^(?(2)a|(1)(2))+$/
3934 123a
3935
3936/(?<=a|bbbb)c/
3937 ac
3938 bbbbc
3939
Nick Kralevichf73ff172014-09-27 12:41:49 -07003940/line\nbreak/
3941 this is a line\nbreak
3942 line one\nthis is a line\nbreak in the second line
3943
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003944/line\nbreak/firstline
Nick Kralevichf73ff172014-09-27 12:41:49 -07003945 this is a line\nbreak
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003946\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003947 line one\nthis is a line\nbreak in the second line
3948
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003949/line\nbreak/m,firstline
Nick Kralevichf73ff172014-09-27 12:41:49 -07003950 this is a line\nbreak
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003951\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07003952 line one\nthis is a line\nbreak in the second line
3953
3954/1234/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003955 123\=ps
3956\= Expect no match
3957 a4\=ps,dfa_restart
Nick Kralevichf73ff172014-09-27 12:41:49 -07003958
3959/1234/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003960 123\=ps
3961 4\=ps,dfa_restart
Nick Kralevichf73ff172014-09-27 12:41:49 -07003962
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003963/^/gm
Nick Kralevichf73ff172014-09-27 12:41:49 -07003964 a\nb\nc\n
3965 \
3966
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003967/(?<=C\n)^/gm
Nick Kralevichf73ff172014-09-27 12:41:49 -07003968 A\nC\nC\n
3969
3970/(?s)A?B/
3971 AB
3972 aB
3973
3974/(?s)A*B/
3975 AB
3976 aB
3977
3978/(?m)A?B/
3979 AB
3980 aB
3981
3982/(?m)A*B/
3983 AB
3984 aB
3985
3986/Content-Type\x3A[^\r\n]{6,}/
3987 Content-Type:xxxxxyyy
3988
3989/Content-Type\x3A[^\r\n]{6,}z/
3990 Content-Type:xxxxxyyyz
3991
3992/Content-Type\x3A[^a]{6,}/
3993 Content-Type:xxxyyy
3994
3995/Content-Type\x3A[^a]{6,}z/
3996 Content-Type:xxxyyyz
3997
Janis Danisevskis53e448c2016-03-31 13:35:25 +01003998/^abc/Im,newline=lf
Nick Kralevichf73ff172014-09-27 12:41:49 -07003999 xyz\nabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004000 xyz\r\nabc
4001\= Expect no match
4002 xyz\rabc
4003 xyzabc\r
4004 xyzabc\rpqr
4005 xyzabc\r\n
4006 xyzabc\r\npqr
4007
4008/^abc/Im,newline=crlf
4009 xyz\r\nabclf>
4010\= Expect no match
4011 xyz\nabclf
4012 xyz\rabclf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004013
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004014/^abc/Im,newline=cr
4015 xyz\rabc
4016\= Expect no match
4017 xyz\nabc
4018 xyz\r\nabc
4019
4020/.*/I,newline=lf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004021 abc\ndef
4022 abc\rdef
4023 abc\r\ndef
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004024
4025/.*/I,newline=cr
4026 abc\ndef
4027 abc\rdef
4028 abc\r\ndef
4029
4030/.*/I,newline=crlf
4031 abc\ndef
4032 abc\rdef
4033 abc\r\ndef
4034
4035/\w+(.)(.)?def/Is
4036 abc\ndef
4037 abc\rdef
4038 abc\r\ndef
Nick Kralevichf73ff172014-09-27 12:41:49 -07004039
4040/\w+(.)(.)?def/s
4041 abc\ndef
4042 abc\rdef
4043 abc\r\ndef
4044
4045/^\w+=.*(\\\n.*)*/
4046 abc=xyz\\\npqr
4047
4048/^(a()*)*/
4049 aaaa
4050
4051/^(?:a(?:(?:))*)*/
4052 aaaa
4053
4054/^(a()+)+/
4055 aaaa
4056
4057/^(?:a(?:(?:))+)+/
4058 aaaa
4059
4060/(a|)*\d/
Nick Kralevichf73ff172014-09-27 12:41:49 -07004061 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004062\= Expect no match
4063 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Nick Kralevichf73ff172014-09-27 12:41:49 -07004064
4065/(?>a|)*\d/
Nick Kralevichf73ff172014-09-27 12:41:49 -07004066 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004067\= Expect no match
4068 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Nick Kralevichf73ff172014-09-27 12:41:49 -07004069
4070/(?:a|)*\d/
Nick Kralevichf73ff172014-09-27 12:41:49 -07004071 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa4
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004072\= Expect no match
4073 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Nick Kralevichf73ff172014-09-27 12:41:49 -07004074
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004075/^a.b/newline=lf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004076 a\rb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004077\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004078 a\nb
Nick Kralevichf73ff172014-09-27 12:41:49 -07004079
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004080/^a.b/newline=cr
4081 a\nb
4082\= Expect no match
4083 a\rb
4084
4085/^a.b/newline=anycrlf
4086 a\x85b
4087\= Expect no match
4088 a\rb
4089
4090/^a.b/newline=any
4091\= Expect no match
4092 a\nb
4093 a\rb
4094 a\x85b
4095
4096/^abc./gmx,newline=any
Nick Kralevichf73ff172014-09-27 12:41:49 -07004097 abc1 \x0aabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\x0aabc6 \x85abc7 JUNK
4098
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004099/abc.$/gmx,newline=any
Nick Kralevichf73ff172014-09-27 12:41:49 -07004100 abc1\x0a abc2\x0b abc3\x0c abc4\x0d abc5\x0d\x0a abc6\x85 abc9
4101
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004102/^a\Rb/bsr=unicode
Nick Kralevichf73ff172014-09-27 12:41:49 -07004103 a\nb
4104 a\rb
4105 a\r\nb
4106 a\x0bb
4107 a\x0cb
4108 a\x85b
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004109\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004110 a\n\rb
4111
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004112/^a\R*b/bsr=unicode
Nick Kralevichf73ff172014-09-27 12:41:49 -07004113 ab
4114 a\nb
4115 a\rb
4116 a\r\nb
4117 a\x0bb
4118 a\x0cb
4119 a\x85b
4120 a\n\rb
4121 a\n\r\x85\x0cb
4122
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004123/^a\R+b/bsr=unicode
Nick Kralevichf73ff172014-09-27 12:41:49 -07004124 a\nb
4125 a\rb
4126 a\r\nb
4127 a\x0bb
4128 a\x0cb
4129 a\x85b
4130 a\n\rb
4131 a\n\r\x85\x0cb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004132\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004133 ab
4134
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004135/^a\R{1,3}b/bsr=unicode
Nick Kralevichf73ff172014-09-27 12:41:49 -07004136 a\nb
4137 a\n\rb
4138 a\n\r\x85b
4139 a\r\n\r\nb
4140 a\r\n\r\n\r\nb
4141 a\n\r\n\rb
4142 a\n\n\r\nb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004143\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004144 a\n\n\n\rb
4145 a\r
4146
Nick Kralevichf73ff172014-09-27 12:41:49 -07004147/.+foo/
4148 afoo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004149\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004150 \r\nfoo
4151 \nfoo
4152
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004153/.+foo/newline=crlf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004154 afoo
4155 \nfoo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004156\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004157 \r\nfoo
4158
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004159/.+foo/newline=any
Nick Kralevichf73ff172014-09-27 12:41:49 -07004160 afoo
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004161\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004162 \nfoo
4163 \r\nfoo
4164
4165/.+foo/s
4166 afoo
4167 \r\nfoo
4168 \nfoo
4169
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004170/^$/gm,newline=any
Nick Kralevichf73ff172014-09-27 12:41:49 -07004171 abc\r\rxyz
4172 abc\n\rxyz
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004173\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004174 abc\r\nxyz
4175
4176/^X/m
4177 XABC
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004178\= Expect no match
4179 XABC\=notbol
Nick Kralevichf73ff172014-09-27 12:41:49 -07004180
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004181/(?m)^$/g,newline=any,aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004182 abc\r\n\r\n
4183
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004184/(?m)^$|^\r\n/g,newline=any,aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004185 abc\r\n\r\n
4186
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004187/(?m)$/g,newline=any,aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004188 abc\r\n\r\n
4189
4190/(?|(abc)|(xyz))/
4191 >abc<
4192 >xyz<
4193
4194/(x)(?|(abc)|(xyz))(x)/
4195 xabcx
4196 xxyzx
4197
4198/(x)(?|(abc)(pqr)|(xyz))(x)/
4199 xabcpqrx
4200 xxyzx
4201
4202/(?|(abc)|(xyz))(?1)/
4203 abcabc
4204 xyzabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004205\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004206 xyzxyz
4207
4208/\H\h\V\v/
4209 X X\x0a
4210 X\x09X\x0b
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004211\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004212 \xa0 X\x0a
4213
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004214/\H*\h+\V?\v{3,4}/
Nick Kralevichf73ff172014-09-27 12:41:49 -07004215 \x09\x20\xa0X\x0a\x0b\x0c\x0d\x0a
4216 \x09\x20\xa0\x0a\x0b\x0c\x0d\x0a
4217 \x09\x20\xa0\x0a\x0b\x0c
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004218\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004219 \x09\x20\xa0\x0a\x0b
4220
4221/\H{3,4}/
4222 XY ABCDE
4223 XY PQR ST
4224
4225/.\h{3,4}./
4226 XY AB PQRS
4227
4228/\h*X\h?\H+Y\H?Z/
4229 >XNNNYZ
4230 > X NYQZ
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004231\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004232 >XYZ
4233 > X NY Z
4234
4235/\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c/
4236 >XY\x0aZ\x0aA\x0bNN\x0c
4237 >\x0a\x0dX\x0aY\x0a\x0bZZZ\x0aAAA\x0bNNN\x0c
4238
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004239/.+A/newline=crlf
4240\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004241 \r\nA
4242
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004243/\nA/newline=crlf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004244 \r\nA
4245
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004246/[\r\n]A/newline=crlf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004247 \r\nA
4248
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004249/(\r|\n)A/newline=crlf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004250 \r\nA
4251
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004252/a\Rb/I,bsr=anycrlf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004253 a\rb
4254 a\nb
4255 a\r\nb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004256\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004257 a\x85b
4258 a\x0bb
4259
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004260/a\Rb/I,bsr=unicode
Nick Kralevichf73ff172014-09-27 12:41:49 -07004261 a\rb
4262 a\nb
4263 a\r\nb
4264 a\x85b
4265 a\x0bb
Nick Kralevichf73ff172014-09-27 12:41:49 -07004266
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004267/a\R?b/I,bsr=anycrlf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004268 a\rb
4269 a\nb
4270 a\r\nb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004271\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004272 a\x85b
4273 a\x0bb
4274
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004275/a\R?b/I,bsr=unicode
Nick Kralevichf73ff172014-09-27 12:41:49 -07004276 a\rb
4277 a\nb
4278 a\r\nb
4279 a\x85b
4280 a\x0bb
Nick Kralevichf73ff172014-09-27 12:41:49 -07004281
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004282/a\R{2,4}b/I,bsr=anycrlf
Nick Kralevichf73ff172014-09-27 12:41:49 -07004283 a\r\n\nb
4284 a\n\r\rb
4285 a\r\n\r\n\r\n\r\nb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004286\= Expect no match
4287 a\x0b\x0bb
4288 a\x85\x85b
Nick Kralevichf73ff172014-09-27 12:41:49 -07004289
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004290/a\R{2,4}b/I,bsr=unicode
Nick Kralevichf73ff172014-09-27 12:41:49 -07004291 a\r\rb
4292 a\n\n\nb
4293 a\r\n\n\r\rb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004294 a\x85\x85b
4295 a\x0b\x0bb
4296\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004297 a\r\r\r\r\rb
Nick Kralevichf73ff172014-09-27 12:41:49 -07004298
4299/a(?!)|\wbc/
4300 abc
4301
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004302/a[]b/alt_bsux,allow_empty_class,match_unset_backref,dupnames
4303\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004304 ab
4305
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004306/a[]+b/alt_bsux,allow_empty_class,match_unset_backref,dupnames
4307\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004308 ab
4309
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004310/a[]*+b/alt_bsux,allow_empty_class,match_unset_backref,dupnames
4311\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004312 ab
4313
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004314/a[^]b/alt_bsux,allow_empty_class,match_unset_backref,dupnames
Nick Kralevichf73ff172014-09-27 12:41:49 -07004315 aXb
4316 a\nb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004317\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004318 ab
4319
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004320/a[^]+b/alt_bsux,allow_empty_class,match_unset_backref,dupnames
Nick Kralevichf73ff172014-09-27 12:41:49 -07004321 aXb
4322 a\nX\nXb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004323\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004324 ab
4325
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004326/X$/dollar_endonly
Nick Kralevichf73ff172014-09-27 12:41:49 -07004327 X
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004328\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004329 X\n
4330
4331/X$/
4332 X
4333 X\n
4334
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004335/xyz/auto_callout
Nick Kralevichf73ff172014-09-27 12:41:49 -07004336 xyz
4337 abcxyz
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004338\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004339 abc
Nick Kralevichf73ff172014-09-27 12:41:49 -07004340 abcxypqr
Nick Kralevichf73ff172014-09-27 12:41:49 -07004341
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004342/xyz/auto_callout,no_start_optimize
4343 abcxyz
4344\= Expect no match
4345 abc
4346 abcxypqr
4347
4348/(*NO_START_OPT)xyz/auto_callout
Nick Kralevichf73ff172014-09-27 12:41:49 -07004349 abcxyz
4350
4351/(?C)ab/
4352 ab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004353 ab\=callout_none
Nick Kralevichf73ff172014-09-27 12:41:49 -07004354
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004355/ab/auto_callout
Nick Kralevichf73ff172014-09-27 12:41:49 -07004356 ab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004357 ab\=callout_none
Nick Kralevichf73ff172014-09-27 12:41:49 -07004358
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004359/^"((?(?=[a])[^"])|b)*"$/auto_callout
Nick Kralevichf73ff172014-09-27 12:41:49 -07004360 "ab"
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004361 "ab"\=callout_none
Nick Kralevichf73ff172014-09-27 12:41:49 -07004362
4363/\d+X|9+Y/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004364 ++++123999\=ps
4365 ++++123999Y\=ps
Nick Kralevichf73ff172014-09-27 12:41:49 -07004366
4367/Z(*F)/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004368\= Expect no match
4369 Z\=ps
4370 ZA\=ps
Nick Kralevichf73ff172014-09-27 12:41:49 -07004371
4372/Z(?!)/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004373\= Expect no match
4374 Z\=ps
4375 ZA\=ps
Nick Kralevichf73ff172014-09-27 12:41:49 -07004376
4377/dog(sbody)?/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004378 dogs\=ps
4379 dogs\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004380
4381/dog(sbody)??/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004382 dogs\=ps
4383 dogs\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004384
4385/dog|dogsbody/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004386 dogs\=ps
4387 dogs\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004388
4389/dogsbody|dog/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004390 dogs\=ps
4391 dogs\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004392
4393/Z(*F)Q|ZXY/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004394 Z\=ps
4395\= Expect no match
4396 ZA\=ps
4397 X\=ps
Nick Kralevichf73ff172014-09-27 12:41:49 -07004398
4399/\bthe cat\b/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004400 the cat\=ps
4401 the cat\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004402
4403/dog(sbody)?/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004404 dogs\=ps
4405 body\=dfa_restart
Nick Kralevichf73ff172014-09-27 12:41:49 -07004406
4407/dog(sbody)?/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004408 dogs\=ph
4409 body\=dfa_restart
Nick Kralevichf73ff172014-09-27 12:41:49 -07004410
4411/abc/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004412 abc\=ps
4413 abc\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004414
4415/abc\K123/
4416 xyzabc123pqr
4417
Elliott Hughes2dbd7d22020-06-03 14:32:37 -07004418/(?<=abc)123/allusedtext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004419 xyzabc123pqr
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004420 xyzabc12\=ps
4421 xyzabc12\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004422
Elliott Hughes2dbd7d22020-06-03 14:32:37 -07004423/\babc\b/allusedtext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004424 +++abc+++
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004425 +++ab\=ps
4426 +++ab\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004427
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004428/(?=C)/g,aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004429 ABCDECBA
4430
4431/(abc|def|xyz)/I
4432 terhjk;abcdaadsfe
4433 the quick xyz brown fox
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004434\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004435 thejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
Nick Kralevichf73ff172014-09-27 12:41:49 -07004436
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004437/(abc|def|xyz)/I,no_start_optimize
Nick Kralevichf73ff172014-09-27 12:41:49 -07004438 terhjk;abcdaadsfe
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004439 the quick xyz brown fox
4440\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004441 thejk;adlfj aenjl;fda asdfasd ehj;kjxyasiupd
Nick Kralevichf73ff172014-09-27 12:41:49 -07004442
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004443/abcd*/aftertext
4444 xxxxabcd\=ps
4445 xxxxabcd\=ph
4446 dddxxx\=dfa_restart
4447 xxxxabcd\=ph
4448 xxx\=dfa_restart
Nick Kralevichf73ff172014-09-27 12:41:49 -07004449
4450/abcd*/i
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004451 xxxxabcd\=ps
4452 xxxxabcd\=ph
4453 XXXXABCD\=ps
4454 XXXXABCD\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004455
4456/abc\d*/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004457 xxxxabc1\=ps
4458 xxxxabc1\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004459
4460/abc[de]*/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004461 xxxxabcde\=ps
4462 xxxxabcde\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004463
4464/(?:(?1)|B)(A(*F)|C)/
4465 ABCD
4466 CCD
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004467\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004468 CAD
4469
4470/^(?:(?1)|B)(A(*F)|C)/
4471 CCD
4472 BCD
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004473\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004474 ABCD
4475 CAD
4476 BAD
4477
4478/^(?!a(*SKIP)b)/
4479 ac
4480
4481/^(?=a(*SKIP)b|ac)/
Nick Kralevichf73ff172014-09-27 12:41:49 -07004482 ac
4483
4484/^(?=a(*THEN)b|ac)/
4485 ac
4486
4487/^(?=a(*PRUNE)b)/
4488 ab
Nick Kralevichf73ff172014-09-27 12:41:49 -07004489
4490/^(?(?!a(*SKIP)b))/
4491 ac
4492
Elliott Hughes2dbd7d22020-06-03 14:32:37 -07004493/(?<=abc)def/allusedtext
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004494 abc\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004495
4496/abc$/
4497 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004498 abc\=ps
4499 abc\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004500
4501/abc$/m
4502 abc
4503 abc\n
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004504 abc\=ph
4505 abc\n\=ph
4506 abc\=ps
4507 abc\n\=ps
Nick Kralevichf73ff172014-09-27 12:41:49 -07004508
4509/abc\z/
4510 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004511 abc\=ps
4512 abc\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004513
4514/abc\Z/
4515 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004516 abc\=ps
4517 abc\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004518
4519/abc\b/
4520 abc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004521 abc\=ps
4522 abc\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004523
4524/abc\B/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004525 abc\=ps
4526 abc\=ph
4527\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004528 abc
Nick Kralevichf73ff172014-09-27 12:41:49 -07004529
4530/.+/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004531 abc\=offset=0
4532 abc\=offset=1
4533 abc\=offset=2
4534\= Bad offsets
4535 abc\=offset=4
4536 abc\=offset=-4
4537\= Expect no match
4538 abc\=offset=3
Nick Kralevichf73ff172014-09-27 12:41:49 -07004539
4540/^(?:a)++\w/
4541 aaaab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004542\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004543 aaaa
4544 bbb
4545
4546/^(?:aa|(?:a)++\w)/
4547 aaaab
4548 aaaa
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004549\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004550 bbb
4551
4552/^(?:a)*+\w/
4553 aaaab
4554 bbb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004555\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004556 aaaa
4557
4558/^(a)++\w/
4559 aaaab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004560\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004561 aaaa
4562 bbb
4563
4564/^(a|)++\w/
4565 aaaab
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004566\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004567 aaaa
4568 bbb
4569
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004570/(?=abc){3}abc/aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004571 abcabcabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004572\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004573 xyz
4574
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004575/(?=abc)+abc/aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004576 abcabcabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004577\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004578 xyz
4579
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004580/(?=abc)++abc/aftertext
Nick Kralevichf73ff172014-09-27 12:41:49 -07004581 abcabcabc
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004582\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004583 xyz
4584
4585/(?=abc){0}xyz/
4586 xyz
4587
4588/(?=abc){1}xyz/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004589\= Expect no match
Nick Kralevichf73ff172014-09-27 12:41:49 -07004590 xyz
4591
4592/(?=(a))?./
4593 ab
4594 bc
4595
4596/(?=(a))??./
4597 ab
4598 bc
4599
4600/^(?=(a)){0}b(?1)/
4601 backgammon
4602
4603/^(?=(?1))?[az]([abc])d/
4604 abd
4605 zcdxx
4606
4607/^(?!a){0}\w+/
4608 aaaaa
4609
4610/(?<=(abc))?xyz/
4611 abcxyz
4612 pqrxyz
4613
4614/((?2))((?1))/
4615 abc
4616
4617/(?(R)a+|(?R)b)/
4618 aaaabcde
4619
4620/(?(R)a+|((?R))b)/
4621 aaaabcde
4622
4623/((?(R)a+|(?1)b))/
4624 aaaabcde
4625
Elliott Hughes9bc971b2018-07-27 13:23:14 -07004626/((?(R2)a+|(?1)b))()/
Nick Kralevichf73ff172014-09-27 12:41:49 -07004627 aaaabcde
4628
4629/(?(R)a*(?1)|((?R))b)/
4630 aaaabcde
4631
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004632/(a+)/no_auto_possess
4633 aaaa\=ovector=3
4634 aaaa\=ovector=4
Nick Kralevichf73ff172014-09-27 12:41:49 -07004635
4636/^\R/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004637 \r\=ps
4638 \r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004639
4640/^\R{2,3}x/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004641 \r\=ps
4642 \r\=ph
4643 \r\r\=ps
4644 \r\r\=ph
4645 \r\r\r\=ps
4646 \r\r\r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004647 \r\rx
4648 \r\r\rx
4649
4650/^\R{2,3}?x/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004651 \r\=ps
4652 \r\=ph
4653 \r\r\=ps
4654 \r\r\=ph
4655 \r\r\r\=ps
4656 \r\r\r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004657 \r\rx
4658 \r\r\rx
4659
4660/^\R?x/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004661 \r\=ps
4662 \r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004663 x
4664 \rx
4665
4666/^\R+x/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004667 \r\=ps
4668 \r\=ph
4669 \r\n\=ps
4670 \r\n\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004671 \rx
4672
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004673/^a$/newline=crlf
4674 a\r\=ps
4675 a\r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004676
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004677/^a$/m,newline=crlf
4678 a\r\=ps
4679 a\r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004680
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004681/^(a$|a\r)/newline=crlf
4682 a\r\=ps
4683 a\r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004684
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004685/^(a$|a\r)/m,newline=crlf
4686 a\r\=ps
4687 a\r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004688
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004689/./newline=crlf
4690 \r\=ps
4691 \r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004692
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004693/.{2,3}/newline=crlf
4694 \r\=ps
4695 \r\=ph
4696 \r\r\=ps
4697 \r\r\=ph
4698 \r\r\r\=ps
4699 \r\r\r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004700
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004701/.{2,3}?/newline=crlf
4702 \r\=ps
4703 \r\=ph
4704 \r\r\=ps
4705 \r\r\=ph
4706 \r\r\r\=ps
4707 \r\r\r\=ph
Nick Kralevichf73ff172014-09-27 12:41:49 -07004708
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004709# Test simple validity check for restarts
Nick Kralevichf73ff172014-09-27 12:41:49 -07004710
4711/abcdef/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004712 abc\=dfa_restart
Nick Kralevichf73ff172014-09-27 12:41:49 -07004713
4714/<H((?(?!<H|F>)(.)|(?R))++)*F>/
4715 text <H more text <H texting more hexA0-"\xA0" hex above 7F-"\xBC" F> text xxxxx <H text F> text F> text2 <H text sample F> more text.
4716
4717/^(?>.{4})abc|^\w\w.xabcd/
4718 xxxxabcd
4719 xx\xa0xabcd
4720
4721/^(.{4}){2}+abc|^\w\w.x\w\w\w\wabcd/
4722 xxxxxxxxabcd
4723 xx\xa0xxxxxabcd
4724
4725/abcd/
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004726 abcd\=ovector=0
Nick Kralevichf73ff172014-09-27 12:41:49 -07004727
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004728# These tests show up auto-possessification
Nick Kralevichf73ff172014-09-27 12:41:49 -07004729
4730/[ab]*/
4731 aaaa
4732
4733/[ab]*?/
4734 aaaa
4735
4736/[ab]?/
4737 aaaa
4738
4739/[ab]??/
4740 aaaa
4741
4742/[ab]+/
4743 aaaa
4744
4745/[ab]+?/
4746 aaaa
4747
4748/[ab]{2,3}/
4749 aaaa
4750
4751/[ab]{2,3}?/
4752 aaaa
4753
4754/[ab]{2,}/
4755 aaaa
4756
4757/[ab]{2,}?/
4758 aaaa
4759
4760'\A(?:[^\"]++|\"(?:[^\"]*+|\"\")*+\")++'
4761 NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
4762
4763'\A(?:[^\"]++|\"(?:[^\"]++|\"\")*+\")++'
4764 NON QUOTED \"QUOT\"\"ED\" AFTER \"NOT MATCHED
4765
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004766/abc(?=xyz)/allusedtext
4767 abcxyzpqr
4768 abcxyzpqr\=aftertext
4769
4770/(?<=pqr)abc(?=xyz)/allusedtext
4771 xyzpqrabcxyzpqr
4772 xyzpqrabcxyzpqr\=aftertext
4773
4774/a\b/
4775 a.\=allusedtext
4776 a\=allusedtext
4777
4778/abc(?=abcde)(?=ab)/allusedtext
4779 abcabcdefg
4780
4781/a*?b*?/
4782 ab
4783
4784/(*NOTEMPTY)a*?b*?/
4785 ab
4786 ba
4787 cb
4788
4789/(*NOTEMPTY_ATSTART)a*?b*?/aftertext
4790 ab
4791 cdab
4792
4793/(a)(b)|(c)/
4794 XcX\=ovector=2,get=1,get=2,get=3,get=4,getall
4795
4796/(?<A>aa)/
4797 aa\=get=A
4798 aa\=copy=A
4799
4800/a+/no_auto_possess
4801 a\=ovector=2,get=1,get=2,getall
4802 aaa\=ovector=2,get=1,get=2,getall
4803
4804/a(b)c(d)/
4805 abc\=ph,copy=0,copy=1,getall
4806
4807/ab(?C" any text with spaces ")cde/B
4808 abcde
4809 12abcde
4810
4811/^a(b)c(?C1)def/
4812 abcdef
4813
4814/^a(b)c(?C"AB")def/
4815 abcdef
4816
4817/^a(b)c(?C1)def/
4818 abcdef\=callout_capture
4819
4820/^a(b)c(?C{AB})def/B
4821 abcdef\=callout_capture
4822
4823/^(?(?C25)(?=abc)abcd|xyz)/B
4824 abcdefg
4825 xyz123
4826
4827/^(?(?C$abc$)(?=abc)abcd|xyz)/B
4828 abcdefg
4829 xyz123
4830
4831/^ab(?C'first')cd(?C"second")ef/
4832 abcdefg
4833
4834/(?:a(?C`code`)){3}X/
4835 aaaXY
4836
4837# Binary zero in callout string
Janis Danisevskis8b979b22016-08-15 16:09:16 +01004838/"a(?C'x" 00 "z')b"/hex
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004839 abcdefgh
4840
Elliott Hughes8366e8b2015-08-14 20:48:15 -07004841/(?(?!)a|b)/
4842 bbb
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004843\= Expect no match
Elliott Hughes8366e8b2015-08-14 20:48:15 -07004844 aaa
4845
Janis Danisevskis53e448c2016-03-31 13:35:25 +01004846/^/gm
4847 \n\n\n
4848
4849/^/gm,alt_circumflex
4850 \n\n\n
4851
4852/abc/use_offset_limit
4853 1234abcde\=offset_limit=100
4854 1234abcde\=offset_limit=9
4855 1234abcde\=offset_limit=4
4856 1234abcde\=offset_limit=4,offset=4
4857\= Expect no match
4858 1234abcde\=offset_limit=4,offset=5
4859 1234abcde\=offset_limit=3
4860
4861/(?<=abc)/use_offset_limit
4862 1234abc\=offset_limit=7
4863\= Expect no match
4864 1234abc\=offset_limit=6
4865
4866/abcd/null_context
4867 abcd\=null_context
4868
Janis Danisevskis8b979b22016-08-15 16:09:16 +01004869/()()a+/no_auto_possess
Elliott Hughes9bc971b2018-07-27 13:23:14 -07004870 aaa\=allcaptures
4871 a\=allcaptures
Janis Danisevskis8b979b22016-08-15 16:09:16 +01004872
Elliott Hughes9bc971b2018-07-27 13:23:14 -07004873/(*LIMIT_DEPTH=100)^((.)(?1)|.)$/
4874\= Expect depth limit exceeded
4875 a[00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]
4876
Elliott Hughes653c2102019-01-09 15:41:36 -08004877/(*LIMIT_HEAP=0)^((.)(?1)|.)$/
4878\= Expect heap limit exceeded
4879 a[00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]
4880
4881/(*LIMIT_HEAP=50000)^((.)(?1)|.)$/
4882\= Expect success
4883 a[00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]
4884
Elliott Hughes9bc971b2018-07-27 13:23:14 -07004885/(02-)?[0-9]{3}-[0-9]{3}/
4886 02-123-123
4887
4888/^(a(?2))(b)(?1)/
4889 abbab\=find_limits
4890
4891/abc/endanchored
4892 xyzabc
4893\= Expect no match
4894 xyzabcdef
4895\= Expect error
4896 xyzabc\=ph
4897
4898/abc/
4899 xyzabc\=endanchored
4900\= Expect no match
4901 xyzabcdef\=endanchored
4902\= Expect error
4903 xyzabc\=ps,endanchored
4904
4905/abc|bcd/endanchored
4906 xyzabcd
4907\= Expect no match
4908 xyzabcdef
4909
4910/(*NUL)^.*/
4911 a\nb\x00ccc
4912
4913/(*NUL)^.*/s
4914 a\nb\x00ccc
4915
4916/^x/m,newline=nul
4917 ab\x00xy
4918
4919/'#comment' 0d 0a 00 '^x\' 0a 'y'/x,newline=nul,hex
4920 x\nyz
4921
4922/(*NUL)^X\NY/
4923 X\nY
4924 X\rY
4925\= Expect no match
4926 X\x00Y
4927
4928/(?<=abc|)/
4929 abcde\=aftertext
4930
4931/(?<=|abc)/
4932 abcde\=aftertext
4933
4934/(?<=abc|)/endanchored
4935 abcde\=aftertext
4936
4937/(?<=|abc)/endanchored
4938 abcde\=aftertext
4939
Elliott Hughes653c2102019-01-09 15:41:36 -08004940/(*LIMIT_MATCH=100).*(?![|H]?.*(?![|H]?););.*(?![|H]?.*(?![|H]?););\x00\x00\x00\x00\x00\x00\x00(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?![|);)?.*(![|H]?);)?.*(?![|H]?);)?.*(?![|H]?);)?.*(?![|H]););![|H]?););[|H]?);|H]?);)\x00\x00\x00 \x00\x00\x00H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););/no_dotstar_anchor
4941\= Expect limit exceeded
4942.*(?![|H]?.*(?![|H]?););.*(?![|H]?.*(?![|H]?););\x00\x00\x00\x00\x00\x00\x00(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?!(?![|);)?.*(![|H]?);)?.*(?![|H]?);)?.*(?![|H]?);)?.*(?![|H]););![|H]?););[|H]?);|H]?);)\x00\x00\x00 \x00\x00\x00H]?););?![|H]?);)?.*(?![|H]?););[||H]?);)?.*(?![|H]?););[|H]?);(?![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););;[\x00\x00\x00\x00\x00\x00\x00![|H]?););![|H]?););[|H]?);|H]?);)?.*(?![|H]?););
Elliott Hughes9bc971b2018-07-27 13:23:14 -07004943
4944/\n/firstline
4945 xyz\nabc
4946
4947/\nabc/firstline
4948 xyz\nabc
4949
4950/\x{0a}abc/firstline,newline=crlf
4951\= Expect no match
4952 xyz\r\nabc
4953
4954/[abc]/firstline
4955\= Expect no match
4956 \na
4957
Elliott Hughes0c26e192019-08-07 12:24:46 -07004958/foobar/
4959 the foobar thing\=copy_matched_subject
4960 the foobar thing\=copy_matched_subject,zero_terminate
4961
4962/foobar/g
4963 the foobar thing foobar again\=copy_matched_subject
4964
4965/(?(VERSION>=0)^B0W)/
4966 B0W-W0W
4967\= Expect no match
4968 0
4969
4970/(?(VERSION>=1000)^B0W|W0W)/
4971 B0W-W0W
4972\= Expect no match
4973 0
4974
Elliott Hughes2dbd7d22020-06-03 14:32:37 -07004975/(?<=pqr)abc(?=xyz)/
4976 123pqrabcxy\=ps,allusedtext
4977 123pqrabcxyz\=ps,allusedtext
4978
4979/(?>a+b)/
4980 aaaa\=ps
4981 aaaab\=ps
4982
4983/(abc)(?1)/
4984 abca\=ps
4985 abcabc\=ps
4986
4987/(?(?=abc).*|Z)/
4988 ab\=ps
4989 abcxyz\=ps
4990
4991/(abc)++x/
4992 abcab\=ps
4993 abc\=ps
4994 ab\=ps
4995 abcx
4996
4997/\z/
4998 abc\=ph
4999 abc\=ps
5000
5001/\Z/
5002 abc\=ph
5003 abc\=ps
5004 abc\n\=ph
5005 abc\n\=ps
5006
5007/c*+(?<=[bc])/
5008 abc\=ph
5009 ab\=ph
5010 abc\=ps
5011 ab\=ps
5012
5013/c++(?<=[bc])/
5014 abc\=ph
5015 ab\=ph
5016
5017/(?<=(?=.(?<=x)))/
5018 abx
5019 ab\=ph
5020 bxyz
5021 xyz
5022
5023/(?![ab]).*/
5024 ab\=ph
5025
5026/c*+/
5027 ab\=ph,offset=2
5028
Janis Danisevskis53e448c2016-03-31 13:35:25 +01005029# End of testinput6