C++ string 分割成 vector 分隔符

用boost的split 

可以指定多种分隔符

#include <iostream>
#include <string>
#include <vector>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
using namespace std;

int main()
{
  string s = "sss/ddd,ggg";
  vector<string> vStr;
  boost::split( vStr, s, boost::is_any_of( ",/" ), boost::token_compress_on );
  for( vector<string>::iterator it = vStr.begin(); it != vStr.end(); ++ it )
  {
    cout << *it << endl;
  }
  return 0;
}

猜你喜欢

转载自blog.csdn.net/u013288190/article/details/128403532