ref: ca5181f70628864f9d4a09e5cbaeaa60801f6729
dir: /test/testmatch.myr/
use std
use regex
pkg =
const testmatch : (pat : byte[:], text : byte[:] -> void)
const dbgmatch : (pat : byte[:], text : byte[:] -> void)
;;
const testmatch = {pat, text
run(regex.compile(pat), text)
}
const dbgmatch = {pat, text
run(regex.dbgcompile(pat), text)
}
const run = {regex, text
var i
match regex
| `std.Success re:
match regex.exec(re, text)
| `std.Some m:
std.put("Matched. %i matches\n", m.len)
for i = 0; i < m.len; i++
std.put("match %i: %s\n", i, m[i])
;;
| `std.None:
std.put("No match\n")
;;
regex.free(re)
| `std.Failure err:
std.put("failed to compile regex")
;;
}