正则表达式验证邮箱
#include "regex.h" bool isEmail(const char *email) { const char *eset = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; regex_t re; regmatch_t subs[10]; regex_t stuRT; regcomp(&stuRT, eset, REG_EXTENDED); int err = regexec(&stuRT, email, (size_t)10, subs, 0); if (err) { regfree (&re); return false; } else { regfree (&re); return true; } }