spliter

来源:互联网 发布:淘宝网折800苹果平板套 编辑:程序博客网 时间:2024/05/16 15:29

 string aa;
    string str("1,2,3,4,5,6,7,8,9");
    string spliter(", ,");

    string::size_type last_pos = str.find_first_not_of(spliter);
    string::size_type cur_pos = last_pos;
    while(cur_pos != string::npos)
    {
        cur_pos = str.find_first_of(spliter, last_pos);
        aa=str.substr(last_pos, cur_pos - last_pos) ;

        cur_pos = str.find_first_not_of(spliter, cur_pos);
        last_pos = cur_pos;
  string bb="aa";
    }