c 正则表达式 账号匹配 、Base64

int CheckAccount(char *str){
int n;
regex_t re;
regmatch_t pm[21];
char buf[256], pattern[256];
//查看account是否格式正确
strcpy(pattern, "^[a-zA-Z0-9_-]+$");
n = regcomp(&re, pattern, REG_EXTENDED);
if (n != 0) {
regerror(n, &re, buf, sizeof(buf));
fprintf(stderr, "err:[%d]%s", n, buf);
regfree(&re);
return n;

}
n = regexec(&re, str, sizeof(pm)/sizeof(regmatch_t), pm, 0);
if (n != 0) {
if (n != REG_NOMATCH) {
regerror(n, &re, buf, sizeof(buf));
fprintf(stderr, "err:[%d]%s", n, buf);
}
regfree(&re);
return n;
}

regfree(&re);
return n;
}





Base64:
         var keycheck = /^[a-zA-Z0-9/+=\\s]*$/g;

你可能感兴趣的:(base64)