2 AnswersNew Answer
The first thing which comes to mind would be <regex>. std::string str = "HatsyRei0123456789"; std::string name = std::regex_replace(str, std::regex("[0-9]"), ""); std::string num = std::regex_replace(str, std::regex("[a-zA-Z]"), ""); std::cout << name << " " << num; For some reason, this works half of the time on Code Playground. The other half gives me "Compilation Error". Desktop site giving me connection issues currently, so I can't test it. However, I can confirm that it's running fine on CodeChef, OnlineGDB, Cpp.sh, etc.
could check it easily by regular expression and show error `/\s/.test(name)`