bool isEmailValid(const std::string& email) {
const std::regex pattern(R"((\w+)(\.|\w+)@\w+(\.\w+)+)");
return std::regex_match(email, pattern);
}
bool isPasswordValid(const std::string& password) {
if (password.length() < 6 || password.length() > 32)
return false;
bool hasDigit = false, hasLetter = false;
for (const auto& c : password) {
if (isdigit(c))
hasDigit = true;
else if (isalpha(c))
hasLetter = true;
if (hasDigit && hasLetter)
return true;
}
return false;
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交