#include <stdio.h>
#include <sys/types.h>
#include <regex.h>
/* 主程序 */
int main(int argc, char** argv)
{
int status,i = 100;
int cflags = REG_EXTENDED;
//int cflags = REG_NEWLINE;
regmatch_t pmatch[1];
const size_t nmatch = 1;
regex_t reg;
const char *pattern = "^\\d+$";
printf("%s\n",pattern);
char buf[] = "12345",buff[1024]={0};
i = regcomp(®,pattern,cflags);
printf("i = %d\n",i);
status = regexec(®,"12345",0,NULL,0);
if(status == REG_NOMATCH)
{
printf("NO Match\n");
regerror (status, ®, buff, 1024);
printf("%s\n",buff);
}
else if(status == 0)
{
printf("Match\n");
}
regfree(®);
return 0;
}
代码如下,求解答!急急急