| 1 |
|
| 2 |
|
| 3 |
(define-syntax let1 |
| 4 |
(syntax-rules () |
| 5 |
((let1 var val body ...) |
| 6 |
(let ((var val)) |
| 7 |
body ...)))) |
| 8 |
|
| 9 |
(define rxmatch irregex-search) |
| 10 |
(define (rxmatch-start m . o) |
| 11 |
(irregex-match-start-index m (if (pair? o) (car o) 0))) |
| 12 |
(define (rxmatch-end m . o) |
| 13 |
(irregex-match-end-index m (if (pair? o) (car o) 0))) |
| 14 |
|
| 15 |
(define (match&list pat input) |
| 16 |
(let ((irx (irregex pat))) |
| 17 |
(cond ((irregex-search irx input) |
| 18 |
=> (lambda (match) |
| 19 |
(map (lambda (n) (irregex-match-substring match n)) |
| 20 |
(iota (+ 1 (irregex-num-submatches irx)))))) |
| 21 |
(else #f)))) |
| 22 |
|
| 23 |
(define (rxmatch-after m . o) |
| 24 |
(substring (car (irregex-match-start-chunk m 0)) |
| 25 |
(irregex-match-end-index m (if (pair? o) (car o) 0)) |
| 26 |
(string-length (car (irregex-match-start-chunk m 0))))) |
| 27 |
|
| 28 |
(define (rxmatch-before m . o) |
| 29 |
(substring (car (irregex-match-start-chunk m 0)) |
| 30 |
0 |
| 31 |
(irregex-match-start-index m (if (pair? o) (car o) 0)))) |
| 32 |
|
| 33 |
(define (rxmatch-substring pat input . o) |
| 34 |
(let ((i (if (pair? o) (car o) 0))) |
| 35 |
(cond ((irregex-search pat input) |
| 36 |
=> (lambda (match) |
| 37 |
(irregex-match-substring match i))) |
| 38 |
(else #f)))) |
| 39 |
|
| 40 |
(test-begin "from-gauche") |
| 41 |
|
| 42 |
(test "a(b)c" '("abc" "b") |
| 43 |
(match&list "a(b)c" "abc")) |
| 44 |
(test "a((b)(c))" '("abc" "bc" "b" "c") |
| 45 |
(match&list "a((b)(c))" "abc")) |
| 46 |
(test "a((((b))))c" '("abc" "b" "b" "b" "b") |
| 47 |
(match&list "a((((b))))c" "abc")) |
| 48 |
(test "a((((b))))c" '#f |
| 49 |
(match&list "a((((b))))c" "a(b)c")) |
| 50 |
(test "a\\(" '("a(") |
| 51 |
(match&list "a\\(" "a(")) |
| 52 |
(test "a()b" '("ab" "") |
| 53 |
(match&list "a()b" "ab")) |
| 54 |
(test "a()()b" '("ab" "" "") |
| 55 |
(match&list "a()()b" "ab")) |
| 56 |
(test "(we|wee|week|frob)(knights|night|day)" |
| 57 |
'("weeknights" "wee" "knights") |
| 58 |
(match&list "(we|wee|week|frob)(knights|night|day)" |
| 59 |
"weeknights")) |
| 60 |
(test "aa|(bb)|cc" '("aa" #f) |
| 61 |
(match&list "aa|(bb)|cc" "aabb")) |
| 62 |
(test "aa|(bb)|cc" '("bb" "bb") |
| 63 |
(match&list "aa|(bb)|cc" "abbaa")) |
| 64 |
(test "aa|(bb)|cc" '("cc" #f) |
| 65 |
(match&list "aa|(bb)|cc" "bccaa")) |
| 66 |
(test "aa|a(b)|cc" '("ab" "b") |
| 67 |
(match&list "aa|a(b)|cc" "abaab")) |
| 68 |
(test "aa|a(b)" '("ab" "b") |
| 69 |
(match&list "aa|a(b)" "abaab")) |
| 70 |
(test "aa|(a(b))|ac" '("ab" "ab" "b") |
| 71 |
(match&list "aa|(a(b))|cc" "abaabcc")) |
| 72 |
(test "(ab)|ac" '("ab" "ab") |
| 73 |
(match&list "(ab)|ac" "aaaabcc")) |
| 74 |
(test "(a(b))|ac" '("ab" "ab" "b") |
| 75 |
(match&list "(a(b))|ac" "abaabcc")) |
| 76 |
(test "ab|(ac)" '("ab" #f) |
| 77 |
(match&list "ab|(ac)" "aaaabcc")) |
| 78 |
(test "ab|(ac)" '("ac" "ac") |
| 79 |
(match&list "ab|(ac)" "aaaacbc")) |
| 80 |
(test "aa|(ab|(ac))|ad" '("ac" "ac" "ac") |
| 81 |
(match&list "aa|(ab|(ac))|ad" "cac")) |
| 82 |
(test "(aa|(a(b)|a(c))|ad)" '("ac" "ac" "ac" #f "c") |
| 83 |
(match&list "(aa|(a(b)|a(c))|ad)" "cac")) |
| 84 |
(test "(.)*" '("abc" "c") |
| 85 |
(match&list "(.)*" "abc")) |
| 86 |
(test "(a([^a])*)*" '("abcaBC" "aBC" "C") |
| 87 |
(match&list "(a([^a])*)*" "abcaBC")) |
| 88 |
(test "b|()|a" '("" "") |
| 89 |
(match&list "b|()|a" "cac")) |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
(test "a.c" '("abc") |
| 95 |
(match&list "a.c" "abc")) |
| 96 |
(test "a.." '("abc") |
| 97 |
(match&list "a.." "abc")) |
| 98 |
(test "a.." #f |
| 99 |
(match&list "a.." "ab")) |
| 100 |
(test "..." #f |
| 101 |
(match&list "..." "ab")) |
| 102 |
(test "." '("a") |
| 103 |
(match&list "." "abc")) |
| 104 |
(test "." #f |
| 105 |
(match&list "." "")) |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
(test "^abc" '("abc") |
| 111 |
(match&list "^abc" "abcd")) |
| 112 |
(test "^abc" #f |
| 113 |
(match&list "^abc" "aabcd")) |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
(test "^abc|def" '("abc") |
| 123 |
(match&list "^abc|def" "abc")) |
| 124 |
(test "^abc|def" #f |
| 125 |
(match&list "^abc|def" "zabc")) |
| 126 |
(test "^abc|def" '("def") |
| 127 |
(match&list "^abc|def" "zabcdef")) |
| 128 |
(test "abc|^def" '("def") |
| 129 |
(match&list "abc|^def" "defabc")) |
| 130 |
(test "abc|^def" '("abc") |
| 131 |
(match&list "abc|^def" "abcdef")) |
| 132 |
(test "abc|^def" '("def") |
| 133 |
(match&list "abc|^def" "defabbc")) |
| 134 |
(test "abc|^def" #f |
| 135 |
(match&list "abc|^def" "adefbc")) |
| 136 |
(test "^(abc|def)" '("abc" "abc") |
| 137 |
(match&list "^(abc|def)" "abc")) |
| 138 |
(test "^(abc|def)" #f |
| 139 |
(match&list "^(abc|def)" "aabc")) |
| 140 |
(test "(^abc|def)" '("abc" "abc") |
| 141 |
(match&list "(^abc|def)" "abcdef")) |
| 142 |
(test "(^abc|def)" '("def" "def") |
| 143 |
(match&list "(^abc|def)" "^abcdef")) |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
(test "^" '("") |
| 149 |
(match&list "^" "hoge")) |
| 150 |
(test "$" '("") |
| 151 |
(match&list "$" "hoge")) |
| 152 |
(test "abc$" '("abc") |
| 153 |
(match&list "abc$" "bcabc")) |
| 154 |
(test "abc$" #f |
| 155 |
(match&list "abc$" "abcab")) |
| 156 |
(test "^abc$" '("abc") |
| 157 |
(match&list "^abc$" "abc")) |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
(test "^$" '("") |
| 165 |
(match&list "^$" "")) |
| 166 |
(test "^$" #f |
| 167 |
(match&list "^$" "a")) |
| 168 |
|
| 169 |
|
| 170 |
(test "abc$|def" '("abc") |
| 171 |
(match&list "abc$|def" "abc")) |
| 172 |
(test "abc$|def" '("def") |
| 173 |
(match&list "abc$|def" "defabc")) |
| 174 |
(test "^abc|def$" '("abc") |
| 175 |
(match&list "^abc|def$" "abcdef")) |
| 176 |
(test "^abc|def$" #f |
| 177 |
(match&list "^abc|def$" "defabc")) |
| 178 |
(test "^abc|def$" #f |
| 179 |
(match&list "^abc|def$" "defabc")) |
| 180 |
(test "(^abc|def$)" '("def" "def") |
| 181 |
(match&list "(^abc|def$)" "aaadef")) |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
(test "ab\\$" '("ab$") |
| 193 |
(match&list "ab\\$" "ab$cd")) |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
(test "a\\*c" '("a*c") |
| 199 |
(match&list "a\\*c" "a*c")) |
| 200 |
(test "a\\.c" '("a.c") |
| 201 |
(match&list "a\\.c" "a.c")) |
| 202 |
(test "a\\.c" #f |
| 203 |
(match&list "a\\.c" "abc")) |
| 204 |
(test "a\\\\b" '("a\\b") |
| 205 |
(match&list "a\\\\b" "a\\b")) |
| 206 |
(test "a\\\\\\*b" '("a\\*b") |
| 207 |
(match&list "a\\\\\\*b" "a\\*b")) |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
(test "a\\\\bc" '("a\\bc") |
| 212 |
(match&list "a\\\\bc" "a\\bc")) |
| 213 |
(test "a\\[b" '("a[b") |
| 214 |
(match&list "a\\[b" "a[b")) |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
(test ".z\\b" '("oz") |
| 220 |
(match&list ".z\\b" "bzbazoz ize")) |
| 221 |
(test "\\b.z" '("iz") |
| 222 |
(match&list "\\b.z" "brzbazoz ize")) |
| 223 |
(test ".z\\B" '("iz") |
| 224 |
(match&list ".z\\B" "bz baz oz ize")) |
| 225 |
(test "\\B.z" '("az") |
| 226 |
(match&list "\\B.z" "bz baz oz ize")) |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
(test "ab*c" '("abc") |
| 232 |
(match&list "ab*c" "abc")) |
| 233 |
(test "ab*c" '("ac") |
| 234 |
(match&list "ab*c" "ac")) |
| 235 |
(test "ab*c" '("abbbc") |
| 236 |
(match&list "ab*c" "abbbc")) |
| 237 |
(test "ab*c" '("abbc") |
| 238 |
(match&list "ab*c" "abbabaabbc")) |
| 239 |
(test "ab+c" '("abc") |
| 240 |
(match&list "ab+c" "abc")) |
| 241 |
(test "ab+c" '("abbc") |
| 242 |
(match&list "ab+c" "abbc")) |
| 243 |
(test "ab+c" '("abbc") |
| 244 |
(match&list "ab+c" "abbabaabbc")) |
| 245 |
(test "ab?c" '("abc") |
| 246 |
(match&list "ab?c" "abc")) |
| 247 |
(test "ab?c" '("ac") |
| 248 |
(match&list "ab?c" "abbaac")) |
| 249 |
(test "a.*c" '("abc") |
| 250 |
(match&list "a.*c" "abc")) |
| 251 |
(test "a.*c" '("aabcabcabcabcc") |
| 252 |
(match&list "a.*c" "zaabcabcabcabcczab")) |
| 253 |
(test "a(b*|c)d" '("abbd" "bb") |
| 254 |
(match&list "a(b*|c)d" "abbd")) |
| 255 |
(test "a(b*|c)d" '("ad" "") |
| 256 |
(match&list "a(b*|c)d" "ad")) |
| 257 |
(test "a(b*|c)d" '("acd" "c") |
| 258 |
(match&list "a(b*|c)d" "acd")) |
| 259 |
(test "a(b*|c)d" #f |
| 260 |
(match&list "a(b*|c)d" "abcd")) |
| 261 |
(test "a.*c" '("ac") |
| 262 |
(match&list "a.*c" "bacbababbbbadbaba")) |
| 263 |
(test "a.*c" #f |
| 264 |
(match&list "a.*c" "abaaaabababbadbabdba")) |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
(test "ab*?." '("ab") |
| 270 |
(match&list "ab*?." "abc")) |
| 271 |
(test "ab*?." '("ac") |
| 272 |
(match&list "ab*?." "ac")) |
| 273 |
(test "a.*?c" '("abbbc") |
| 274 |
(match&list "a.*?c" "abbbc")) |
| 275 |
(test "a.*?a" '("abba") |
| 276 |
(match&list "a.*?a" "abbabaabbc")) |
| 277 |
(test "<.*?>" '("<tag1>") |
| 278 |
(match&list "<.*?>" "<tag1><tag2><tag3>")) |
| 279 |
|
| 280 |
(test "ab+?." '("abc") |
| 281 |
(match&list "ab+?." "abc")) |
| 282 |
(test "ab+?." '("abb") |
| 283 |
(match&list "ab+?." "abbc")) |
| 284 |
(test "a.+?a" '("abba") |
| 285 |
(match&list "a.+?a" "abbabaabbc")) |
| 286 |
(test "<.+?>" '("<><tag1>") |
| 287 |
(match&list "<.+?>" " <><tag1><tag2>")) |
| 288 |
|
| 289 |
(test "ab??c" '("abc") |
| 290 |
(match&list "ab??c" "abc")) |
| 291 |
(test "ab??c" '("ac") |
| 292 |
(match&list "ab??c" "abbaac")) |
| 293 |
(test "ab??." '("ab") |
| 294 |
(match&list "ab??." "abbaac")) |
| 295 |
(test "a(hoge)??hoge" '("ahoge" #f) |
| 296 |
(match&list "a(hoge)??hoge" "ahogehoge")) |
| 297 |
(test "(foo)??bar" '("foobar" "foo") |
| 298 |
(match&list "(foo)??bar" "foobar")) |
| 299 |
(test "(foo)??bar" '("foobar" "foo") |
| 300 |
(match&list "(foo)??bar" "foofoobar")) |
| 301 |
(test "(foo)*?bar" '("foofoobar" "foo") |
| 302 |
(match&list "(foo)*?bar" "foofoobar")) |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
(test "a[bc]d" '("abd") |
| 308 |
(match&list "a[bc]d" "abd")) |
| 309 |
(test "a[bc]d" '("acd") |
| 310 |
(match&list "a[bc]d" "acd")) |
| 311 |
(test "a[bc]d" #f |
| 312 |
(match&list "a[bc]d" "aed")) |
| 313 |
(test "a[a-z]d" '("aed") |
| 314 |
(match&list "a[a-z]d" "aed")) |
| 315 |
(test "a[a-z]d" #f |
| 316 |
(match&list "a[a-z]d" "aEd")) |
| 317 |
(test "a[]]d" '("a]d") |
| 318 |
(match&list "a[]]d" "a]d")) |
| 319 |
(test "a[]-]d" '("a-d") |
| 320 |
(match&list "a[]-]d" "a-d")) |
| 321 |
(test "a[]-^]d" #f |
| 322 |
(match&list "a[]-^]d" "a-d")) |
| 323 |
(test "a[]-^]d" '("a]d") |
| 324 |
(match&list "a[]-^]d" "a]d")) |
| 325 |
(test "a[a-z-]d" '("a-d") |
| 326 |
(match&list "a[a-z-]d" "a-d")) |
| 327 |
(test "a[a-z-]d" '("afd") |
| 328 |
(match&list "a[a-z-]d" "afd")) |
| 329 |
(test "a[az-]d" '("a-d") |
| 330 |
(match&list "a[az-]d" "a-d")) |
| 331 |
(test "a[a-]d" '("a-d") |
| 332 |
(match&list "a[a-]d" "a-d")) |
| 333 |
(test "a[az-]d" #f |
| 334 |
(match&list "a[az-]d" "afd")) |
| 335 |
(test "a[az-]d" '("azd") |
| 336 |
(match&list "a[az-]d" "azd")) |
| 337 |
(test "a[^ab]c" '("acc") |
| 338 |
(match&list "a[^ab]c" "abacc")) |
| 339 |
(test "a[^]]c" '("abc") |
| 340 |
(match&list "a[^]]c" "abc")) |
| 341 |
(test "a[^]]c" #f |
| 342 |
(match&list "a[^]]c" "a]c")) |
| 343 |
(test "a[^^]c" '("abc") |
| 344 |
(match&list "a[^^]c" "abc")) |
| 345 |
(test "a[^^]c" #f |
| 346 |
(match&list "a[^^]c" "a^c")) |
| 347 |
(test "a[Bc]*d" '("aBccBd") |
| 348 |
(match&list "a[Bc]*d" "aBccBd")) |
| 349 |
(test "[a]b[c]" '("abc") |
| 350 |
(match&list "[a]b[c]" "abc")) |
| 351 |
(test "[abc]b[abc]" '("abc") |
| 352 |
(match&list "[abc]b[abc]" "abc")) |
| 353 |
(test "a[bc]d" '("abd") |
| 354 |
(match&list "a[bc]d" "xyzaaabcaababdacd")) |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
(test "a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)" |
| 361 |
'("aaaaabaaaabweeknights" "wee" "knights") |
| 362 |
(match&list "a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)" |
| 363 |
"aaaaabaaaabweeknights")) |
| 364 |
(test "[ab][cd][ef][gh][ij][kl][mn]" |
| 365 |
'("acegikm") |
| 366 |
(match&list "[ab][cd][ef][gh][ij][kl][mn]" |
| 367 |
"xacegikmoq")) |
| 368 |
(test "[ab][cd][ef][gh][ij][kl][mn][op]" |
| 369 |
'("acegikmo") |
| 370 |
(match&list "[ab][cd][ef][gh][ij][kl][mn][op]" |
| 371 |
"xacegikmoq")) |
| 372 |
(test "[ab][cd][ef][gh][ij][kl][mn][op][qr]" |
| 373 |
'("acegikmoq") |
| 374 |
(match&list "[ab][cd][ef][gh][ij][kl][mn][op][qr]" |
| 375 |
"xacegikmoqy")) |
| 376 |
(test "[ab][cd][ef][gh][ij][kl][mn][op][q]" |
| 377 |
'("acegikmoq") |
| 378 |
(match&list "[ab][cd][ef][gh][ij][kl][mn][op][q]" |
| 379 |
"xacegikmoqy")) |
| 380 |
|
| 381 |
|
| 382 |
(test "[^a]*." '("b") |
| 383 |
(match&list "[^a]*." "b")) |
| 384 |
|
| 385 |
(test "\\s" '(" ") (match&list "\\s" " ")) |
| 386 |
(test "\\s" '(" ") (match&list "\\s\\s" " ")) |
| 387 |
(test "\\s" '("\t") (match&list "\\s" "\t ")) |
| 388 |
(test "\\s" #f (match&list "\\s\\s" "\\s")) |
| 389 |
(test "\\\\s" '("\\s ") (match&list "\\\\s\\s" "\\s ")) |
| 390 |
(test "\\s\\S" '("\txyz " "\t" "xyz" " ") |
| 391 |
(match&list "(\\s*)(\\S+)(\\s*)" "\txyz abc")) |
| 392 |
(test "\\d\\D" '("1234) 5678-9012" "1234" ") " "5678" "-" "9012") |
| 393 |
(match&list "(\\d+)(\\D+)(\\d+)(\\D+)(\\d+)" |
| 394 |
" (1234) 5678-9012 ")) |
| 395 |
(test "\\w\\W" '("three o" "three" " " "o") |
| 396 |
(match&list "(\\w+)(\\W+)(\\w+)" |
| 397 |
"three o'clock")) |
| 398 |
|
| 399 |
(test "[ab\\sc]+" '(" ba ") (match&list "[ab\\sc]+" "d ba e")) |
| 400 |
(test "[\\sa-c]+" '(" ba ") (match&list "[\\sabc]+" "d ba e")) |
| 401 |
(test "[\\S\\t]+" '("\tab") (match&list "[\\S\\t]+" "\tab cd")) |
| 402 |
(test "[\\s\\d]+" '(" 1 2 3 ") |
| 403 |
(match&list "[\\s\\d]+" "a 1 2 3 b ")) |
| 404 |
(test "[\\s\\D]+" '("a ") |
| 405 |
(match&list "[\\s\\D]+" "a 1 2 3 b ")) |
| 406 |
|
| 407 |
|
| 408 |
(test "^\\[?([^\\]]*)\\]?:(\\d+)$" '("127.0.0.1:80" "127.0.0.1" "80") |
| 409 |
(match&list "^\\[?([^\\]]*)\\]?:(\\d+)$" "127.0.0.1:80")) |
| 410 |
(test "^\\[?([^\\]]*)\\]?:(\\d+)$" '("[127.0.0.1:80" "127.0.0.1" "80") |
| 411 |
(match&list "^\\[?([^\\]]*)\\]?:(\\d+)$" "[127.0.0.1:80")) |
| 412 |
(test "^\\[?([^\\]]*)\\]?:(\\d+)$" '("[127.0.0.1]:80" "127.0.0.1" "80") |
| 413 |
(match&list "^\\[?([^\\]]*)\\]?:(\\d+)$" "[127.0.0.1]:80")) |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
(test "a{2}" "aabaa" (rxmatch-after (irregex-search "a{2}" "abaaaabaa"))) |
| 419 |
(test "a{2,}" "baa" (rxmatch-after (irregex-search "a{2,}" "abaaaabaa"))) |
| 420 |
(test "a{1,2}" "baaaabaa" (rxmatch-after (irregex-search "a{1,2}" "abaaaabaa"))) |
| 421 |
(test "a{2,3}" "abaa" (rxmatch-after (irregex-search "a{2,3}" "abaaaabaa"))) |
| 422 |
(test "a{b,c}" "def" (rxmatch-after (irregex-search "a{b,c}" "za{b,c}def"))) |
| 423 |
(test-error (rxmatch-after (irregex-search "a{,2}*" "za{,2}}def"))) |
| 424 |
|
| 425 |
(test "(ab){2}" "abba" (rxmatch-after (irregex-search "(ab){2}" "babbabababba"))) |
| 426 |
(test "(ab){2,2}" "abba" (rxmatch-after (irregex-search "(ab){2,2}" "babbabababba"))) |
| 427 |
(test "(ab){2,}" "ba" (rxmatch-after (irregex-search "(ab){2,}" "babbabababba"))) |
| 428 |
(test "(ab){1,2}" "babababba" (rxmatch-after (irregex-search "(ab){1,2}" "babbabababba"))) |
| 429 |
(test "(ab){2,3}" "ba" (rxmatch-after (irregex-search "(ab){2,3}" "babbabababba"))) |
| 430 |
(test "(ab){b,c}" "def" (rxmatch-after (irregex-search "(ab){b,c}" "zab{b,c}def"))) |
| 431 |
|
| 432 |
(test "(\\d{2})(\\d{2})" '("1234" "12" "34") |
| 433 |
(match&list "(\\d{2})(\\d{2})" "a12345b")) |
| 434 |
(test "(\\d{2,})(\\d{2,})" '("12345" "123" "45") |
| 435 |
(match&list "(\\d{2,})(\\d{2,})" "a12345b")) |
| 436 |
(test "(\\d{2})(\\d{2,})" '("12345" "12" "345") |
| 437 |
(match&list "(\\d{2})(\\d{2,})" "a12345b")) |
| 438 |
(test "(\\d{1,3})(\\d{2,})" '("1234" "12" "34") |
| 439 |
(match&list "(\\d{1,3})(\\d{2,})" "a1234b")) |
| 440 |
(test "(\\d{1,3})(\\d{0,2})" '("1234" "123" "4") |
| 441 |
(match&list "(\\d{1,3})(\\d{0,2})" "a1234b")) |
| 442 |
(test "(\\d{2}){2}" '("1234" "34") |
| 443 |
(match&list "(\\d{2}){2}" "a12345b")) |
| 444 |
|
| 445 |
(test-error (irregex "{2}")) |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
(test-error (irregex "{300}")) |
| 450 |
(test-error (irregex "{3,1}")) |
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
(test "a{2}?" "aabaa" (rxmatch-after (irregex-search "a{2}?" "abaaaabaa"))) |
| 456 |
(test "a{2,}?" "aabaa" (rxmatch-after (irregex-search "a{2,}?" "abaaaabaa"))) |
| 457 |
(test "a{1,2}?" "baaaabaa" (rxmatch-after (irregex-search "a{1,2}?" "abaaaabaa"))) |
| 458 |
(test "a{2,3}?" "aabaa" (rxmatch-after (irregex-search "a{2,3}?" "abaaaabaa"))) |
| 459 |
|
| 460 |
(test "(ab){2}?" "abba" (rxmatch-after (irregex-search "(ab){2}?" "babbabababba"))) |
| 461 |
(test "(ab){2,2}?" "abba" (rxmatch-after (irregex-search "(ab){2,2}?" "babbabababba"))) |
| 462 |
(test "(ab){2,}?" "abba" (rxmatch-after (irregex-search "(ab){2,}?" "babbabababba"))) |
| 463 |
(test "(ab){1,2}?" "babababba" (rxmatch-after (irregex-search "(ab){1,2}?" "babbabababba"))) |
| 464 |
(test "(ab){2,3}?" "abba" (rxmatch-after (irregex-search "(ab){2,3}?" "babbabababba"))) |
| 465 |
|
| 466 |
(test "(\\d{2,}?)(\\d{2,}?)" '("1234" "12" "34") |
| 467 |
(match&list "(\\d{2,}?)(\\d{2,}?)" "a12345b")) |
| 468 |
(test "(\\d{2,})(\\d{2,}?)" '("12345" "123" "45") |
| 469 |
(match&list "(\\d{2,})(\\d{2,}?)" "a12345b")) |
| 470 |
(test "(\\d{2,}?)(\\d{2,})" '("12345" "12" "345") |
| 471 |
(match&list "(\\d{2,}?)(\\d{2,})" "a12345b")) |
| 472 |
(test "(\\d{1,3}?)(\\d{2,}?)" '("123" "1" "23") |
| 473 |
(match&list "(\\d{1,3}?)(\\d{2,}?)" "a1234b")) |
| 474 |
(test "(\\d{1,3}?)(\\d{0,2}?)" '("1" "1" "") |
| 475 |
(match&list "(\\d{1,3}?)(\\d{0,2}?)" "a1234b")) |
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
(test "a(?:b)*c(d)" "d" |
| 481 |
(rxmatch-substring "a(?:b)*c(d)" "abcdbcdefg" 1)) |
| 482 |
(test "a(?:bcd)*e(f)" "f" |
| 483 |
(rxmatch-substring "a(?:bcd)*e(f)" "abcdbcdefg" 1)) |
| 484 |
(test "a(?:bcd)*e(f)" "f" |
| 485 |
(rxmatch-substring "a(?:bcd)*e(f)" "aefg" 1)) |
| 486 |
(test "a(?:bcd)+e(f)" #f |
| 487 |
(rxmatch-substring "a(?:bcd)+e(f)" "aefg" 1)) |
| 488 |
(test "a(?:bc(de(?:fg)?hi)jk)?l" "defghi" |
| 489 |
(rxmatch-substring "a(?:bc(de(?:fg)?hi)jk)?l" "abcdefghijkl" 1)) |
| 490 |
(test "a(?:bc(de(?:fg)?hi)jk)?l" "dehi" |
| 491 |
(rxmatch-substring "a(?:bc(de(?:fg)?hi)jk)?l" "abcdehijkl" 1)) |
| 492 |
|
| 493 |
(test "a(?i:bc)d" "aBCd" |
| 494 |
(rxmatch-substring "a(?i:bc)d" "!aBCd!")) |
| 495 |
(test "a(?i:bc)d" #f |
| 496 |
(rxmatch-substring "a(?i:bc)d" "!aBCD!")) |
| 497 |
(test "a(?i:[a-z]+)d" "aBcd" |
| 498 |
(rxmatch-substring "a(?i:[a-z]+)d" "!aBcd!")) |
| 499 |
(test "a(?i:[a-z]+)d" #f |
| 500 |
(rxmatch-substring "a(?i:[a-z]+)d" "!ABcd!")) |
| 501 |
|
| 502 |
(test "A(?-i:Bc)D" "ABcD" |
| 503 |
(rxmatch-substring "A(?-i:Bc)D" "!ABcD!")) |
| 504 |
(test "A(?-i:Bc)D" #f |
| 505 |
(rxmatch-substring "A(?-i:Bc)D" "!ABcd!")) |
| 506 |
(test "A(?-i:[A-Z]+)D" "ABCD" |
| 507 |
(rxmatch-substring "A(?-i:[A-Z]+)D" "!ABCD!")) |
| 508 |
(test "A(?-i:[A-Z]+)D" #f |
| 509 |
(rxmatch-substring "A(?-i:[A-Z]+)D" "!abCD!")) |
| 510 |
|
| 511 |
(test "A(?-i:Bc)D/i" "aBcd" |
| 512 |
(rxmatch-substring "(?i)A(?-i:Bc)D" "!aBcd!")) |
| 513 |
(test "A(?-i:Bc)D/i" #f |
| 514 |
(rxmatch-substring "(?i)A(?-i:Bc)D" "!abCd!")) |
| 515 |
(test "A(?-i:[A-Z]+)D/i" "aBCd" |
| 516 |
(rxmatch-substring "(?i)A(?-i:[A-Z]+)D" "!aBCd!")) |
| 517 |
(test "A(?-i:[A-Z]+)D/i" #f |
| 518 |
(rxmatch-substring "(?i)A(?-i:[A-Z]+)D" "!abcd!")) |
| 519 |
|
| 520 |
|
| 521 |
(test "^(?i:a*).$" "b" |
| 522 |
(rxmatch-substring "^(?i:a*).$" "b")) |
| 523 |
(test "^(?i:a*).$" "a" |
| 524 |
(rxmatch-substring "^(?i:a*).$" "a")) |
| 525 |
(test "^(?i:a*).$" "A" |
| 526 |
(rxmatch-substring "^(?i:a*).$" "A")) |
| 527 |
(test "^(?i:a*).$" "Ab" |
| 528 |
(rxmatch-substring "^(?i:a*).$" "Ab")) |
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
(test "^(.)\\1$" '("aa" "a") |
| 533 |
(match&list "^(.)\\1$" "aa")) |
| 534 |
(test "^(.)\\1$" #f |
| 535 |
(match&list "^(.)\\1$" "ab")) |
| 536 |
(test "(.+)\\1" '("123123" "123") |
| 537 |
(match&list "(.+)\\1" "a123123j")) |
| 538 |
(test "/(.+)\\1/i" '("AbCaBC" "AbC") |
| 539 |
(match&list "(?i)(.+)\\1" "AbCaBC")) |
| 540 |
(test "/(.+)\\1/i" #f |
| 541 |
(match&list "(.+)\\1" "AbCAb1")) |
| 542 |
(test-error (string->irregex "^\\1(.)")) |
| 543 |
(test-error (string->irregex "^(\\1)$")) |
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
(test "(?>.*\\/)foo" #f |
| 548 |
(match&list "(?>.*\\/)foo" "/this/is/a/long/line/")) |
| 549 |
(test "(?>.*\\/)foo" '("/this/is/a/long/line/foo") |
| 550 |
(match&list "(?>.*\\/)foo" "/this/is/a/long/line/foo")) |
| 551 |
(test "(?>(\\.\\d\\d[1-9]?))\\d+" '(".230003938" ".23") |
| 552 |
(match&list "(?>(\\.\\d\\d[1-9]?))\\d+" "1.230003938")) |
| 553 |
(test "(?>(\\.\\d\\d[1-9]?))\\d+" '(".875000282" ".875") |
| 554 |
(match&list "(?>(\\.\\d\\d[1-9]?))\\d+" "1.875000282")) |
| 555 |
(test "(?>(\\.\\d\\d[1-9]?))\\d+" #f |
| 556 |
(match&list "(?>(\\.\\d\\d[1-9]?))\\d+" "1.235")) |
| 557 |
(test "^((?>\\w+)|(?>\\s+))*$" '("foo bar" "bar") |
| 558 |
(match&list "^((?>\\w+)|(?>\\s+))*$" "foo bar")) |
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
(test "^(?=ab(de))(abd)(e)" '("abde" "de" "abd" "e") |
| 577 |
(match&list "^(?=ab(de))(abd)(e)" "abde")) |
| 578 |
(test "^(?!(ab)de|x)(abd)(f)" '("abdf" #f "abd" "f") |
| 579 |
(match&list "^(?!(ab)de|x)(abd)(f)" "abdf")) |
| 580 |
(test "^(?=(ab(cd)))(ab)" '("ab" "abcd" "cd" "ab") |
| 581 |
(match&list "^(?=(ab(cd)))(ab)" "abcd")) |
| 582 |
(test "\\w+(?=\\t)" '("brown") |
| 583 |
(match&list "\\w+(?=\t)" "the quick brown\t fox")) |
| 584 |
(test "foo(?!bar)(.*)" '("foolish see?" "lish see?") |
| 585 |
(match&list "foo(?!bar)(.*)" "foobar is foolish see?")) |
| 586 |
(test "(?:(?!foo)...|^.{0,2})bar(.*)" '("rowbar etc" " etc") |
| 587 |
(match&list "(?:(?!foo)...|^.{0,2})bar(.*)" "foobar crowbar etc")) |
| 588 |
(test "(?:(?!foo)...|^.{0,2})bar(.*)" '("barrel" "rel") |
| 589 |
(match&list "(?:(?!foo)...|^.{0,2})bar(.*)" "barrel")) |
| 590 |
(test "(?:(?!foo)...|^.{0,2})bar(.*)" '("2barrel" "rel") |
| 591 |
(match&list "(?:(?!foo)...|^.{0,2})bar(.*)" "2barrel")) |
| 592 |
(test "(?:(?!foo)...|^.{0,2})bar(.*)" '("A barrel" "rel") |
| 593 |
(match&list "(?:(?!foo)...|^.{0,2})bar(.*)" "A barrel")) |
| 594 |
(test "^(\\D*)(?=\\d)(?!123)" '("abc" "abc") |
| 595 |
(match&list "^(\\D*)(?=\\d)(?!123)" "abc456")) |
| 596 |
(test "^(\\D*)(?=\\d)(?!123)" #f |
| 597 |
(match&list "^(\\D*)(?=\\d)(?!123)" "abc123")) |
| 598 |
(test "(?!^)abc" '("abc") |
| 599 |
(match&list "(?!^)abc" "the abc")) |
| 600 |
(test "(?!^)abc" #f |
| 601 |
(match&list "(?!^)abc" "abc")) |
| 602 |
(test "(?=^)abc" '("abc") |
| 603 |
(match&list "(?=^)abc" "abc")) |
| 604 |
(test "(?=^)abc" #f |
| 605 |
(match&list "(?=^)abc" "the abc")) |
| 606 |
(test "(\\.\\d\\d((?=0)|\\d(?=\\d)))" '(".23" ".23" "") |
| 607 |
(match&list "(\\.\\d\\d((?=0)|\\d(?=\\d)))" "1.230003938")) |
| 608 |
(test "(\\.\\d\\d((?=0)|\\d(?=\\d)))" '(".875" ".875" "5") |
| 609 |
(match&list "(\\.\\d\\d((?=0)|\\d(?=\\d)))" "1.875000282")) |
| 610 |
(test "(\\.\\d\\d((?=0)|\\d(?=\\d)))" #f |
| 611 |
(match&list "(\\.\\d\\d((?=0)|\\d(?=\\d)))" "1.235")) |
| 612 |
(test "^\\D*(?!123)" '("AB") |
| 613 |
(match&list "^\\D*(?!123)" "ABC123")) |
| 614 |
(test "^(\\D*)(?=\\d)(?!123)" '("ABC" "ABC") |
| 615 |
(match&list "^(\\D*)(?=\\d)(?!123)" "ABC445")) |
| 616 |
(test "^(\\D*)(?=\\d)(?!123)" #f |
| 617 |
(match&list "^(\\D*)(?=\\d)(?!123)" "ABC123")) |
| 618 |
(test "a(?!b)." '("ad") |
| 619 |
(match&list "a(?!b)." "abad")) |
| 620 |
(test "a(?!b)" '("a") |
| 621 |
(match&list "a(?!b)" "abad")) |
| 622 |
(test "a(?=d)." '("ad") |
| 623 |
(match&list "a(?=d)." "abad")) |
| 624 |
(test "a(?=c|d)." '("ad") |
| 625 |
(match&list "a(?=c|d)." "abad")) |
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
(test "(?<=a)b" #f |
| 630 |
(match&list "(?<=a)b" "b")) |
| 631 |
(test "(?<=a)b" '("b") |
| 632 |
(match&list "(?<=a)b" "ab")) |
| 633 |
(test "(?<=a+)b" '("b") |
| 634 |
(match&list "(?<=a+)b" "aab")) |
| 635 |
(test "(?<=x[yz])b" '("b") |
| 636 |
(match&list "(?<=x[yz])b" "xzb")) |
| 637 |
(test "(?<=zyx)b" #f |
| 638 |
(match&list "(?<=zyx)b" "xyzb")) |
| 639 |
(test "(?<=[ab]+)c" '("c") |
| 640 |
(match&list "(?<=[ab]+)c" "abc")) |
| 641 |
(test "(?<!<[^>]*)foo" #f |
| 642 |
(match&list "(?<!<[^>]*)foo" "<foo>")) |
| 643 |
|
| 644 |
|
| 645 |
(test "(?<=^a)b" '("b") |
| 646 |
(match&list "(?<=^a)b" "ab")) |
| 647 |
(test "(?<=^)b" #f |
| 648 |
(match&list "(?<=^)b" "ab")) |
| 649 |
(test "(?<=^)b" '("b") |
| 650 |
(match&list "(?<=^)b" "b")) |
| 651 |
(test ".(?<=\\^)b" '("^b") |
| 652 |
(match&list ".(?<=\\^)b" "a^b")) |
| 653 |
(test "(?<=^a$)" '("") |
| 654 |
(match&list "(?<=^a$)" "a")) |
| 655 |
(test "(?<=^a\\$)b" '("b") |
| 656 |
(match&list "(?<=^a\\$)b" "a$b")) |
| 657 |
(test "(?<=(a))b" '("b" "a") |
| 658 |
(match&list "(?<=(a))b" "ab")) |
| 659 |
(test "(?<=(a)(b))c" '("c" "a" "b") |
| 660 |
(match&list "(?<=(a)(b))c" "abc")) |
| 661 |
(test "(?<=(a)|(b))c" '("c" #f "b") |
| 662 |
(match&list "(?<=(a)|(b))c" "bc")) |
| 663 |
(test "(?<=(?<!foo)bar)baz" '("baz") |
| 664 |
(match&list "(?<=(?<!foo)bar)baz" "abarbaz")) |
| 665 |
(test "(?<=(?<!foo)bar)baz" #f |
| 666 |
(match&list "(?<=(?<!foo)bar)baz" "foobarbaz")) |
| 667 |
(test "(?<=\\d{3})(?<!999)foo" '("foo") |
| 668 |
(match&list "(?<=\\d{3})(?<!999)foo" "865foo")) |
| 669 |
(test "(?<=\\d{3})(?<!999)foo" #f |
| 670 |
(match&list "(?<=\\d{3})(?<!999)foo" "999foo")) |
| 671 |
|
| 672 |
|
| 673 |
(test "(abc)...(?<=\\1)" '("abcabc" "abc") |
| 674 |
(match&list "(abc)...(?<=\\1)" "abcabc")) |
| 675 |
(test "/(abC)...(?<=\\1)/i" '("abCAbc" "abC") |
| 676 |
(match&list "(?i)(abC)...(?<=\\1)" "abCAbc")) |
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
(test "(?<foo>a)" '("a" "a") |
| 681 |
(match&list "(?<foo>a)" "a")) |
| 682 |
(test "(?<foo>a)" "a" |
| 683 |
(let1 m (irregex-search "(?<foo>a)" "a") |
| 684 |
(irregex-match-substring m 'foo))) |
| 685 |
(test "(?<foo>a)" #f |
| 686 |
(let1 m (irregex-search "(?<foo>a)?" "b") |
| 687 |
(irregex-match-substring m 'foo))) |
| 688 |
(test "(?<foo>a)(?<bar>.*)" '("a" "bcd") |
| 689 |
(let1 m (irregex-search "(?<foo>a)(?<bar>.*)" "abcd") |
| 690 |
(list (irregex-match-substring m 'foo) |
| 691 |
(irregex-match-substring m 'bar)))) |
| 692 |
(test "(?<foo>a)(?<bar>.*)" '("abcd" "a" "bcd") |
| 693 |
(match&list "(?<foo>a)(?<bar>.*)" "abcd")) |
| 694 |
(test-error |
| 695 |
(let1 m (irregex-search "(?<foo>a)" "abcd") |
| 696 |
(irregex-match-substring m 'bar))) |
| 697 |
(test "(?<foo>^a$)" '("a" "a") |
| 698 |
(match&list "(?<foo>^a$)" "a")) |
| 699 |
(test "(?<foo>^a$)" #f |
| 700 |
(match&list "(?<foo>^a$)" "ab")) |
| 701 |
(test "(?<name-with-hyphen>a)" '("a" "a") |
| 702 |
(match&list "(?<name-with-hyphen>a)" "a")) |
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
(test "(?<foo>.+)\\k<foo>" '("abcabc" "abc") |
| 719 |
(match&list "(?<foo>.+)\\k<foo>" "abcabc")) |
| 720 |
(test "(?<foo>.+)\\k<foo>" #f |
| 721 |
(match&list "(?<foo>.+)\\k<foo>" "abcdef")) |
| 722 |
(test-error (irregex "\\k<foo>")) |
| 723 |
(test "rxmatch-before" "abc" |
| 724 |
(rxmatch-before (irregex-search "(?<foo>def)" "abcdefghi") 'foo)) |
| 725 |
(test "rxmatch-after" "ghi" |
| 726 |
(rxmatch-after (irregex-search "(?<foo>def)" "abcdefghi") 'foo)) |
| 727 |
(test "rxmatch-start" 3 |
| 728 |
(rxmatch-start (irregex-search "(?<foo>def)" "abcdefghi") 'foo)) |
| 729 |
(test "rxmatch-end" 6 |
| 730 |
(rxmatch-end (irregex-search "(?<foo>def)" "abcdefghi") 'foo)) |
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
(test "(a)(?(1)b)" '("ab" "a") |
| 735 |
(match&list "(a)(?(1)b)" "ab")) |
| 736 |
(test "(a)(?(1)b)" #f |
| 737 |
(match&list "(a)(?(1)b)" "aa")) |
| 738 |
(test "(a)(?(1)b|c)" #f |
| 739 |
(match&list "(a)(?(1)b)" "ac")) |
| 740 |
(test "(a)?(?(1)b|c)" #f |
| 741 |
(match&list "(a)?(?(1)b|c)" "xb")) |
| 742 |
(test "(a)?(?(1)b|c)" '("c" #f) |
| 743 |
(match&list "(a)?(?(1)b|c)" "xc")) |
| 744 |
(test "(?(?<=a)b)" '("b") |
| 745 |
(match&list "(?(?<=a)b)" "ab")) |
| 746 |
(test "(?(?<=a)b)" #f |
| 747 |
(match&list "(?(?<=a)b)" "ac")) |
| 748 |
(test "(?(?<=a)b)" #f |
| 749 |
(match&list "(?(?<=a)b)" "xb")) |
| 750 |
(test "(?(?<=a)b|c)" '("b") |
| 751 |
(match&list "(?(?<=a)b)" "ab")) |
| 752 |
(test "(?(?<=a)b|c)" #f |
| 753 |
(match&list "(?(?<=a)b)" "ac")) |
| 754 |
(test-error (irregex "(?(?a)b|c)")) |
| 755 |
(test "()(?(1))" '("" "") |
| 756 |
(match&list "()(?(1))" "")) |
| 757 |
|
| 758 |
(test-error (irregex "()((?(")) |
| 759 |
(test-error (irregex "()((?(1")) |
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
(test "regexp/ci" "BC" |
| 888 |
(cond ((rxmatch "(?i)bc" "ABCD") |
| 889 |
=> irregex-match-substring) |
| 890 |
(else #f))) |
| 891 |
(test "regexp/ci" "bC" |
| 892 |
(cond ((rxmatch "(?i)Bc" "AbCD") |
| 893 |
=> irregex-match-substring) |
| 894 |
(else #f))) |
| 895 |
(test "regexp/ci" "bc" |
| 896 |
(cond ((rxmatch "(?i)BC" "AbcD") |
| 897 |
=> irregex-match-substring) |
| 898 |
(else #f))) |
| 899 |
(test "regexp/ci" #f |
| 900 |
(cond ((rxmatch "Bc" "AbCD") |
| 901 |
=> irregex-match-substring) |
| 902 |
(else #f))) |
| 903 |
(test "regexp/ci" #f |
| 904 |
(cond ((rxmatch "BC" "ABcD") |
| 905 |
=> irregex-match-substring) |
| 906 |
(else #f))) |
| 907 |
(test "regexp/ci" "PAD" |
| 908 |
(cond ((rxmatch "(?i)p[a-z]d" "PAD") |
| 909 |
=> irregex-match-substring) |
| 910 |
(else #f))) |
| 911 |
(test "regexp/ci" "pad" |
| 912 |
(cond ((rxmatch "(?i)P[A-Z]D" "pad") |
| 913 |
=> irregex-match-substring) |
| 914 |
(else #f))) |
| 915 |
(test "regexp/ci" "bad" |
| 916 |
(cond ((rxmatch "(?i).[a-pQ-Z][A-Pq-z]" "bad") |
| 917 |
=> irregex-match-substring) |
| 918 |
(else #f))) |
| 919 |
(test "regexp/ci" #f |
| 920 |
(cond ((rxmatch "p[a-z]d" "PAD") |
| 921 |
=> irregex-match-substring) |
| 922 |
(else #f))) |
| 923 |
(test "regexp/ci" #f |
| 924 |
(cond ((rxmatch "P[A-Z]D" "pad") |
| 925 |
=> irregex-match-substring) |
| 926 |
(else #f))) |
| 927 |
(test "regexp/ci" #f |
| 928 |
(cond ((rxmatch ".[a-pQ-Z][A-Pq-z]" "bad") |
| 929 |
=> irregex-match-substring) |
| 930 |
(else #f))) |
| 931 |
(test "regexp/ci" "pad" |
| 932 |
(cond ((rxmatch (string->irregex "p[A-Z]d" 'case-insensitive) "pad") |
| 933 |
=> irregex-match-substring) |
| 934 |
(else #f))) |
| 935 |
(test "regexp/ci" #f |
| 936 |
(cond ((rxmatch (string->irregex "p[A-Z]d") "pad") |
| 937 |
=> irregex-match-substring) |
| 938 |
(else #f))) |
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
(test-assert "regexp-quote" |
| 977 |
(let ((str "^(#$%#}{)\\-+?^$")) |
| 978 |
(irregex-match (string->irregex (irregex-quote str)) str))) |
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
(test-end) |