알고리즘/codefights
27>variableName
Diademata
2017. 7. 6. 14:04
반응형
Correct variable names consist only of Latin letters, digits and underscores and they can't start with a digit. Check if the given string is a correct variable name. Example For name = "var_1__Int", the output should be variableName(name) = true; For name = "qq-q", the output should be variableName(name) = false; For name = "2w2", the output should be variableName(name) = false. |
code>>
bool variableName(std::string name) {
std::regex r("^[a-z|A-Z|_.][a-zA-Z_0-9]*");
return regex_match(name, r);
}
반응형