[root@devel3 root]# cat test.c #include #include int main(int argc, char *argv[]) { int i; char *pat = "^[A-Z]+$"; printf("Got %d args\n", argc-1 ); /* first arg prog name */ for( i=1; iMatch %s\n", pat); } else { printf("***Fail\n"); } } return 0; } int match(const char *string, char *pattern) { int status; regex_t re; if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) { return(0); /* report error */ } status = regexec(&re, string, (size_t) 0, NULL, 0); regfree(&re); if (status != 0) { return(0); /* report error */ } return(1); } [root@devel3 root]# gcc test.c [root@devel3 root]# ./a.out 123 ABC abc ABC123 Got 4 args Got 123 ***Fail Got ABC -->Match ^[A-Z]+$ Got abc ***Fail Got ABC123 ***Fail [root@devel3 root]#