#include <stdio.h>
#include <sys/types.h>
#include <regex.h>
int main(int argc,char**argv)
{
int status;
int i;
int cflags = REG_EXTENDED;
regmatch_t pmatch[1];
const size_t nmatch =1 ;
regex_t reg;
const char * pattern="^[A-Z]{2}\\w+@\\w{6}_\\w+.\\w+$";
//const char * pattern="^[A-Z]{2}\\w+$";
//const char * pattern="^\\w$";
regcomp(®,pattern,cflags);
status=regexec(®,argv[1],nmatch,pmatch,0);
printf("%s",argv[1]);
if(status == REG_NOMATCH)
printf("no Match\n");
else if(status ==0)
{
printf("match\n");
}
}
匹配AA1111@111111_0.0格式的字符串
正则表达式实例(c语言)
最新推荐文章于 2024-06-27 16:07:23 发布