#include
#include
#include
#include
int
match(char *str, char *regstr, char *flags)
{
int i;
int ret = 0;
regex_t regex;
regex_t *preg = ®ex;
int cflags = REG_EXTENDED;
memset(preg, 0, sizeof(regex_t));
for (i = 0; flags[i] != '\0'; ++i)
switch (flags[i]) {
case 'i':
cflags |= REG_ICASE; break;
}
if (0 != regcomp(preg, regstr, cflags)) {
fprintf(stderr, "regcomp failed: %s\n", strerror(errno));
return (-1);
}
ret = regexec(preg, str, 0, NULL, 0);
regfree(preg);
return ret;
}
阅读(1380) | 评论(0) | 转发(0) |