美文网首页
C++ 代码库

C++ 代码库

作者: 陈成_Adam | 来源:发表于2021-09-06 20:41 被阅读0次

    去掉字符串的首尾空格

     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


    相关文章

      网友评论

          本文标题:C++ 代码库

          本文链接:https://www.haomeiwen.com/subject/ytsywltx.html