/* Run one test with tre_reguexec */ static void test_reguexec(const char *str, const char *regex) { regex_t preg; tre_str_source *source; regmatch_t pmatch[5]; source = make_str_source(str); if (!source) return; tre_regcomp(&preg, regex, REG_EXTENDED); if (tre_reguexec(&preg, source, elementsof(pmatch), pmatch, 0) == 0) printf("Match: %d - %d\n", (int)pmatch[0].rm_so, (int)pmatch[0].rm_eo); free_str_source(source); tre_regfree(&preg); }
int main(int argc, char **argv) { regex_t preg; tre_str_source *source; regmatch_t pmatch[5]; source = make_str_source("xfoofofoofoo"); if (!source) return 1; regcomp(&preg, "(foo)\\1", REG_EXTENDED); if (reguexec(&preg, source, elementsof(pmatch), pmatch, 0) == 0) printf("Match: %d - %d\n", (int)pmatch[0].rm_so, (int)pmatch[0].rm_eo); free_str_source(source); return 0; }