5 #include "libre9/re9.h"
8 int main (int argc
, char *argv
[]) {
12 fprintf(stderr
, "usage: %s regexp substr string string...\n", argv
[0]);
15 p
= re9_compile(argv
[1], RE9_FLAG_NONUTF8
, &errmsg
);
16 if (p
== NULL
) { fprintf(stderr
, "FATAL: invalid regexp '%s': %s\n", argv
[1], errmsg
); return 1; }
17 for (int f
= 3; f
< argc
; ++f
) {
19 if (f
> 3) printf("===============================\n");
20 if (re9_execute(p
, RE9_FLAG_NONUTF8
, argv
[f
], rs
, 10)) {
21 static char dst
[8192];
22 int sz
= re9_subst(dst
, sizeof(dst
), argv
[2], rs
, re9_nsub(p
));
23 printf(" nsub=%d; sub %s -> <%s> (%d)\n", re9_nsub(p
), argv
[2], dst
, sz
);