| 1 |
[[test]] |
| 2 |
name = "1" |
| 3 |
regex = "a" |
| 4 |
haystack = "aaa" |
| 5 |
matches = [[0, 1], [1, 2], [2, 3]] |
| 6 |
|
| 7 |
[[test]] |
| 8 |
name = "2" |
| 9 |
regex = "a" |
| 10 |
haystack = "aba" |
| 11 |
matches = [[0, 1], [2, 3]] |
| 12 |
|
| 13 |
[[test]] |
| 14 |
name = "empty1" |
| 15 |
regex = '' |
| 16 |
haystack = '' |
| 17 |
matches = [[0, 0]] |
| 18 |
|
| 19 |
[[test]] |
| 20 |
name = "empty2" |
| 21 |
regex = '' |
| 22 |
haystack = 'abc' |
| 23 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 24 |
|
| 25 |
[[test]] |
| 26 |
name = "empty3" |
| 27 |
regex = '(?:)' |
| 28 |
haystack = 'abc' |
| 29 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 30 |
|
| 31 |
[[test]] |
| 32 |
name = "empty4" |
| 33 |
regex = '(?:)*' |
| 34 |
haystack = 'abc' |
| 35 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 36 |
|
| 37 |
[[test]] |
| 38 |
name = "empty5" |
| 39 |
regex = '(?:)+' |
| 40 |
haystack = 'abc' |
| 41 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 42 |
|
| 43 |
[[test]] |
| 44 |
name = "empty6" |
| 45 |
regex = '(?:)?' |
| 46 |
haystack = 'abc' |
| 47 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 48 |
|
| 49 |
[[test]] |
| 50 |
name = "empty7" |
| 51 |
regex = '(?:)(?:)' |
| 52 |
haystack = 'abc' |
| 53 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 54 |
|
| 55 |
[[test]] |
| 56 |
name = "empty8" |
| 57 |
regex = '(?:)+|z' |
| 58 |
haystack = 'abc' |
| 59 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 60 |
|
| 61 |
[[test]] |
| 62 |
name = "empty9" |
| 63 |
regex = 'z|(?:)+' |
| 64 |
haystack = 'abc' |
| 65 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 66 |
|
| 67 |
[[test]] |
| 68 |
name = "empty10" |
| 69 |
regex = '(?:)+|b' |
| 70 |
haystack = 'abc' |
| 71 |
matches = [[0, 0], [1, 1], [2, 2], [3, 3]] |
| 72 |
|
| 73 |
[[test]] |
| 74 |
name = "empty11" |
| 75 |
regex = 'b|(?:)+' |
| 76 |
haystack = 'abc' |
| 77 |
matches = [[0, 0], [1, 2], [3, 3]] |
| 78 |
|
| 79 |
[[test]] |
| 80 |
name = "start1" |
| 81 |
regex = "^a" |
| 82 |
haystack = "a" |
| 83 |
matches = [[0, 1]] |
| 84 |
|
| 85 |
[[test]] |
| 86 |
name = "start2" |
| 87 |
regex = "^a" |
| 88 |
haystack = "aa" |
| 89 |
matches = [[0, 1]] |
| 90 |
|
| 91 |
[[test]] |
| 92 |
name = "anchored1" |
| 93 |
regex = "a" |
| 94 |
haystack = "a" |
| 95 |
matches = [[0, 1]] |
| 96 |
anchored = true |
| 97 |
|
| 98 |
# This test is pretty subtle. It demonstrates the crucial difference between |
| 99 |
# '^a' and 'a' compiled in 'anchored' mode. The former regex exclusively |
| 100 |
# matches at the start of a haystack and nowhere else. The latter regex has |
| 101 |
# no such restriction, but its automaton is constructed such that it lacks a |
| 102 |
# `.*?` prefix. So it can actually produce matches at multiple locations. |
| 103 |
# The anchored3 test drives this point home. |
| 104 |
[[test]] |
| 105 |
name = "anchored2" |
| 106 |
regex = "a" |
| 107 |
haystack = "aa" |
| 108 |
matches = [[0, 1], [1, 2]] |
| 109 |
anchored = true |
| 110 |
|
| 111 |
# Unlikely anchored2, this test stops matching anything after it sees `b` |
| 112 |
# since it lacks a `.*?` prefix. Since it is looking for 'a' but sees 'b', it |
| 113 |
# determines that there are no remaining matches. |
| 114 |
[[test]] |
| 115 |
name = "anchored3" |
| 116 |
regex = "a" |
| 117 |
haystack = "aaba" |
| 118 |
matches = [[0, 1], [1, 2]] |
| 119 |
anchored = true |
| 120 |
|
| 121 |
[[test]] |
| 122 |
name = "nonempty-followedby-empty" |
| 123 |
regex = 'abc|.*?' |
| 124 |
haystack = "abczzz" |
| 125 |
matches = [[0, 3], [4, 4], [5, 5], [6, 6]] |
| 126 |
|
| 127 |
[[test]] |
| 128 |
name = "nonempty-followedby-oneempty" |
| 129 |
regex = 'abc|.*?' |
| 130 |
haystack = "abcz" |
| 131 |
matches = [[0, 3], [4, 4]] |
| 132 |
|
| 133 |
[[test]] |
| 134 |
name = "nonempty-followedby-onemixed" |
| 135 |
regex = 'abc|.*?' |
| 136 |
haystack = "abczabc" |
| 137 |
matches = [[0, 3], [4, 7]] |
| 138 |
|
| 139 |
[[test]] |
| 140 |
name = "nonempty-followedby-twomixed" |
| 141 |
regex = 'abc|.*?' |
| 142 |
haystack = "abczzabc" |
| 143 |
matches = [[0, 3], [4, 4], [5, 8]] |