去掉字符串的首尾空格
void trim(string &s)
{
if( !s.empty() )
{
s.erase(0,s.find_first_not_of(" "));
s.erase(s.find_last_not_of(" ") + 1);
}
}
详细参考:https://www.cnblogs.com/Shirlies/p/4666744.html
匹配QQ号
std::regex qq_reg("[1-9]\\d{4,11}");
bool ret = std::regex_match(qq, qq_reg);
std::cout << (ret ? "valid" : "invalid") << std::endl;
详细参考:https://www.cnblogs.com/coolcpp/p/cpp-regex.html
网友评论