Exemplo n.º 1
0
R_API int r_regex_match (const char *pattern, const char *flags, const char *text) {
	int ret;
	RRegex rx;
	int re_flags = r_regex_flags (flags);
	if (r_regex_comp (&rx, pattern, re_flags)) {
		eprintf ("FAIL TO COMPILE %s\n", pattern);
		return 0;
	}
	ret = r_regex_exec (&rx, text, 0, 0, re_flags);
	if (!ret) {
eprintf ("OK! (%s)\n", text);
		if (!strstr (text, "raxq")) {
			eprintf ("FALSE POSITIVE with (%s)\n", pattern);
		}
	}
	r_regex_fini (&rx);
	return ret? 0: 1;
#if 0
	regex_t preg;
	regmatch_t pmatch[NUM_MATCHES];
	if (regcomp(&preg, reg, REG_EXTENDED))
		return -1;
	return (regexec (&preg, str, NUM_MATCHES, pmatch, 0))?1:0;
#endif
}
Exemplo n.º 2
0
R_API RRegex *r_regex_new (const char *pattern, const char *flags) {
	RRegex rx, *r;
	if (r_regex_comp (&rx, pattern, r_regex_flags (flags)))
		return NULL;
	r = malloc (sizeof (RRegex));
	memcpy (r, &rx, sizeof (RRegex));
	return r;
}
Exemplo n.º 3
0
R_API int r_regex_match (const char *pattern, const char *flags, const char *text) {
	int ret;
	RRegex rx;
	if (r_regex_comp (&rx, pattern, r_regex_flags (flags)))
		return -1;
	ret = r_regex_exec (&rx, text, 0, 0, 0);
	r_regex_fini (&rx);
	return ret? 0: 1;
#if 0
	regex_t preg;
	regmatch_t pmatch[NUM_MATCHES];
	if (regcomp(&preg, reg, REG_EXTENDED))
		return -1;
	return (regexec (&preg, str, NUM_MATCHES, pmatch, 0))?1:0;
#endif
}