#define _XOPEN_SOURCE 700 #include #include #include #include int main (void) { regex_t reg; const char *pattern = "[[:digit:]]"; const char *s = "0"; int cflags = REG_NOSUB; assert(regcomp(®, pattern, cflags) == 0); if (regexec(®, s, 0, NULL, 0) == REG_NOMATCH) { printf("regexec: %s did not match /%s/\n", s, pattern); } else { printf("regexec: %s matched /%s/\n", s, pattern); } regfree(®); if (fnmatch(pattern, s, 0) == FNM_NOMATCH) { printf("fnmatch: %s did not match /%s/\n", s, pattern); } else { printf("fnmatch: %s matched /%s/\n", s, pattern); } }