C++分割字符串

来源:互联网 发布:哪件商品能在淘宝发布 编辑:程序博客网 时间:2024/06/16 19:26
            std::string str_value = "123/456/789";            std::string id = "";            std::size_t start_pos;            for(start_pos = 0; start_pos != std::string::npos; )            {                std::size_t pos = str_value.find_first_of("/",start_pos);                if(pos != std::string::npos)                {                           id = str_value.substr(start_pos,pos-start_pos);                    //if(OutNumberRuleManager_T::instance()->IsOutNumberRuleMatch(id)) //out call user                    //{                        tmpUserList.push_back(id);                   // }                    start_pos = pos+1;                }                else                {                    id = str_value.substr(start_pos,std::string::npos-start_pos);                    //if(OutNumberRuleManager_T::instance()->IsOutNumberRuleMatch(id)) //out call user                    //{                        tmpUserList.push_back(id);                    //}                    break;                }            }


如上以“/"为界限分割字符串

0 0
原创粉丝点击