반응형
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);
}
반응형
'알고리즘 > codefights' 카테고리의 다른 글
29>chessBoardCellColor (0) | 2017.07.06 |
---|---|
28>alphabeticShift (0) | 2017.07.06 |
26>evenDigitsOnly (0) | 2017.07.06 |
25>arrayReplace (0) | 2017.07.06 |
24>minesweeper (0) | 2017.07.06 |